\subsection{Cardano.BM.Counters.Dummy} \label{code:Cardano.BM.Counters.Dummy} This is a dummy definition of |readCounters| on platforms that do not support the 'proc' filesystem from which we would read the counters. The only supported measurements are monotonic clock time and RTS statistics for now. %if style == newcode \begin{code} {-# LANGUAGE CPP #-} module Cardano.BM.Counters.Dummy ( readCounters , readResourceStats ) where #ifdef ENABLE_OBSERVABLES import Cardano.BM.Counters.Common (getMonoClock, readRTSStats) import Cardano.BM.Data.Observable import Cardano.BM.Stats.Resources #endif import Cardano.BM.Data.Aggregated (Measurable(..)) import Cardano.BM.Data.Counter import Cardano.BM.Data.SubTrace \end{code} %endif \label{code:Dummy.readCounters}\index{Counters!Dummy!readCounters} \begin{code} readResourceStats :: IO (Maybe ResourceStats) readResourceStats :: IO (Maybe ResourceStats) readResourceStats = Maybe ResourceStats -> IO (Maybe ResourceStats) forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe ResourceStats -> IO (Maybe ResourceStats)) -> (ResourceStats -> Maybe ResourceStats) -> ResourceStats -> IO (Maybe ResourceStats) forall b c a. (b -> c) -> (a -> b) -> a -> c . ResourceStats -> Maybe ResourceStats forall a. a -> Maybe a Just (ResourceStats -> IO (Maybe ResourceStats)) -> ResourceStats -> IO (Maybe ResourceStats) forall a b. (a -> b) -> a -> b $ Word64 -> ResourceStats forall (f :: * -> *) a. Applicative f => a -> f a pure Word64 0 readCounters :: SubTrace -> IO [Counter] readCounters :: SubTrace -> IO [Counter] readCounters SubTrace NoTrace = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] readCounters SubTrace Neutral = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] readCounters (TeeTrace LoggerName _) = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] readCounters (FilterTrace [(DropName, UnhideNames)] _) = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] readCounters SubTrace UntimedTrace = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] readCounters SubTrace DropOpening = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] readCounters (SetSeverity Severity _) = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [] #ifdef ENABLE_OBSERVABLES readCounters (ObservableTraceSelf [ObservableInstance] tts) = [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [ObservableInstance] tts [] readCounters (ObservableTrace ProcessID _ [ObservableInstance] tts) = [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [ObservableInstance] tts [] readCounters' :: [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' :: [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [] [Counter] acc = [Counter] -> IO [Counter] forall (m :: * -> *) a. Monad m => a -> m a return [Counter] acc readCounters' (ObservableInstance MonotonicClock : [ObservableInstance] r) [Counter] acc = IO [Counter] getMonoClock IO [Counter] -> ([Counter] -> IO [Counter]) -> IO [Counter] forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= \[Counter] xs -> [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [ObservableInstance] r ([Counter] -> IO [Counter]) -> [Counter] -> IO [Counter] forall a b. (a -> b) -> a -> b $ [Counter] acc [Counter] -> [Counter] -> [Counter] forall a. [a] -> [a] -> [a] ++ [Counter] xs readCounters' (ObservableInstance GhcRtsStats : [ObservableInstance] r) [Counter] acc = IO [Counter] readRTSStats IO [Counter] -> ([Counter] -> IO [Counter]) -> IO [Counter] forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= \[Counter] xs -> [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [ObservableInstance] r ([Counter] -> IO [Counter]) -> [Counter] -> IO [Counter] forall a b. (a -> b) -> a -> b $ [Counter] acc [Counter] -> [Counter] -> [Counter] forall a. [a] -> [a] -> [a] ++ [Counter] xs readCounters' (ObservableInstance SysStats : [ObservableInstance] r) [Counter] acc = [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [ObservableInstance] r ([Counter] -> IO [Counter]) -> [Counter] -> IO [Counter] forall a b. (a -> b) -> a -> b $ [Counter] acc [Counter] -> [Counter] -> [Counter] forall a. [a] -> [a] -> [a] ++ [CounterType -> LoggerName -> Measurable -> Counter Counter CounterType SysInfo LoggerName "Platform" (Integer -> Measurable PureI (Integer -> Measurable) -> Integer -> Measurable forall a b. (a -> b) -> a -> b $ Int -> Integer forall a b. (Integral a, Num b) => a -> b fromIntegral (Int -> Integer) -> Int -> Integer forall a b. (a -> b) -> a -> b $ Platform -> Int forall a. Enum a => a -> Int fromEnum Platform UnknownPlatform)] readCounters' (ObservableInstance _ : [ObservableInstance] r) [Counter] acc = [ObservableInstance] -> [Counter] -> IO [Counter] readCounters' [ObservableInstance] r [Counter] acc #else readCounters (ObservableTraceSelf _) = return [Counter SysInfo "Platform" (PureI $ fromIntegral $ fromEnum UnknownPlatform)] readCounters (ObservableTrace _ _) = return [] #endif \end{code}