| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Hermod.Tracing.API
Description
Stable public API for the Hermod tracing system.
This is the single-import front door for hermod-tracing-api. It
re-exports everything a package needs to:
- Define trace types: write
LogFormatting(human/machine rendering, metrics) andMetaTrace(namespace, severity, documentation) instances for your domain message types. - Dispatch messages: call
traceWithto emit,contramapMto adapt types,foldTraceMto accumulate state,routingTraceto fan out. - Filter:
filterTrace,filterTraceMaybe.
For tracer authors
Trace -- the central carrier opaque type LogFormatting(..) -- typeclass: forMachine, forHuman, asMetrics MetaTrace(..) -- typeclass: namespaceFor, severityFor, documentFor, … Metric(..) -- metric payload (IntM, DoubleM, CounterM, LabelSetM) Namespace(..) -- hierarchical trace identifier SeverityS(..) -- message severity (Debug … Emergency) SeverityF(..) -- severity filter (Nothing = Silence) Privacy(..) -- Public | Confidential DetailLevel(..) -- DMinimal … DMaximum Folding(..) -- wrapper for fold-based stateful tracers
Configuration and control (consumed by hermod-tracing-core)
TraceConfig, ConfigOption, BackendConfig,
ConfigReflection, DocCollector, ForwarderAddr,
ForwarderMode, TraceOptionForwarder, PrometheusSimpleRun.
These appear in type signatures throughout the system; tracer authors
typically do not construct them directly.
Synopsis
- data Trace (m :: Type -> Type) a
- newtype Folding a b = Folding b
- data CounterAction
- data DetailLevel
- data Metric
- data Namespace a = Namespace {}
- data Privacy
- newtype SeverityF = SeverityF (Maybe SeverityS)
- data SeverityS
- data BackendConfig
- = Forwarder
- | Stdout FormatLogging
- | EKGBackend
- | DatapointBackend
- | PrometheusSimple Bool (Maybe HostName) PortNumber
- data ConfigOption
- = ConfSeverity { }
- | ConfDetail { }
- | ConfBackend {
- backends :: [BackendConfig]
- | ConfLimiter { }
- data FormatLogging
- data ForwarderMode
- data PrometheusSimpleRun = PrometheusSimpleRun {}
- data TraceConfig = TraceConfig {}
- data TraceOptionForwarder = TraceOptionForwarder {}
- data Verbosity
- data ConfigReflection = ConfigReflection {}
- newtype DocCollector = DocCollector (IORef (Map Int LogDoc))
- class LogFormatting a where
- forMachine :: DetailLevel -> a -> Object
- forHuman :: a -> Text
- asMetrics :: a -> [Metric]
- class MetaTrace a where
- namespaceFor :: a -> Namespace a
- severityFor :: Namespace a -> Maybe a -> Maybe SeverityS
- privacyFor :: Namespace a -> Maybe a -> Maybe Privacy
- detailsFor :: Namespace a -> Maybe a -> Maybe DetailLevel
- documentFor :: Namespace a -> Maybe Text
- metricsDocFor :: Namespace a -> [(Text, Text)]
- allNamespaces :: [Namespace a]
- traceWith :: Monad m => Trace m a -> a -> m ()
- unfold :: Folding a b -> b
- routingTrace :: Monad m => (a -> m (Trace m a)) -> Trace m a -> Trace m a
- filterTraceMaybe :: forall (m :: Type -> Type) a. Monad m => Trace m a -> Trace m (Maybe a)
- emptyLoggingContext :: LoggingContext
- getMetricName :: Metric -> Text
- nsCast :: Namespace a -> Namespace b
- nsGetComplete :: Namespace a -> [Text]
- nsGetTuple :: Namespace a -> ([Text], [Text])
- nsPrependInner :: Text -> Namespace a -> Namespace b
- nsRawToText :: ([Text], [Text]) -> Text
- nsReplaceInner :: [Text] -> Namespace a -> Namespace a
- nsReplacePrefix :: [Text] -> Namespace a -> Namespace a
- nsToText :: Namespace a -> Text
- defaultForwarder :: TraceOptionForwarder
- emptyTraceConfig :: TraceConfig
- parsePrometheusString :: Text -> Either String BackendConfig
- prometheusSimpleNoOverrides :: PrometheusSimpleRun
- emptyConfigReflection :: IO ConfigReflection
- emptyLogDoc :: Text -> [(Text, Text)] -> LogDoc
- contramapM :: Monad m => Trace m b -> (a -> m b) -> Trace m a
- contramapMCond :: Monad m => Trace m b -> (a -> m (Maybe b)) -> Trace m a
- foldTraceM :: forall a acc m. MonadUnliftIO m => (acc -> a -> m acc) -> acc -> Trace m (Folding a acc) -> m (Trace m a)
- foldCondTraceM :: forall a acc m. MonadUnliftIO m => (acc -> a -> m acc) -> acc -> (a -> Bool) -> Trace m (Folding a acc) -> m (Trace m a)
- filterTrace :: Monad m => (a -> Bool) -> Trace m a -> Trace m a
Documentation
Constructors
| Folding b |
Instances
| LogFormatting b => LogFormatting (Folding a b) | |
Defined in Hermod.Tracing.Types | |
data CounterAction #
Constructors
| CounterIncrement | |
| CounterAdd Word64 |
Instances
| Generic CounterAction | |
Defined in Hermod.Tracing.Types.Annotations Methods from :: CounterAction -> Rep CounterAction x Source # to :: Rep CounterAction x -> CounterAction Source # | |
| Show CounterAction | |
Defined in Hermod.Tracing.Types.Annotations | |
| NFData CounterAction | |
Defined in Hermod.Tracing.Types.Annotations Methods rnf :: CounterAction -> () Source # | |
| Eq CounterAction | |
Defined in Hermod.Tracing.Types.Annotations Methods (==) :: CounterAction -> CounterAction -> Bool Source # (/=) :: CounterAction -> CounterAction -> Bool Source # | |
| type Rep CounterAction | |
Defined in Hermod.Tracing.Types.Annotations type Rep CounterAction = D1 ('MetaData "CounterAction" "Hermod.Tracing.Types.Annotations" "hermod-tracing-api-1.0.0-LO80W9OfQJv10WJ5Ly2Uoc-internal" 'False) (C1 ('MetaCons "CounterIncrement" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CounterAdd" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word64))) | |
data DetailLevel #
Instances
Constructors
| IntM Text Integer | |
| DoubleM Text Double | |
| CounterM Text CounterAction | |
| LabelSetM Text [(Text, Text)] |
Instances
Constructors
| Confidential | |
| Public |
Instances
| Bounded Privacy | |
| Enum Privacy | |
Defined in Hermod.Tracing.Types.Annotations Methods succ :: Privacy -> Privacy Source # pred :: Privacy -> Privacy Source # toEnum :: Int -> Privacy Source # fromEnum :: Privacy -> Int Source # enumFrom :: Privacy -> [Privacy] Source # enumFromThen :: Privacy -> Privacy -> [Privacy] Source # enumFromTo :: Privacy -> Privacy -> [Privacy] Source # enumFromThenTo :: Privacy -> Privacy -> Privacy -> [Privacy] Source # | |
| Generic Privacy | |
| Show Privacy | |
| Eq Privacy | |
| Ord Privacy | |
Defined in Hermod.Tracing.Types.Annotations | |
| Serialise Privacy | |
Defined in Hermod.Tracing.Types.Annotations | |
| type Rep Privacy | |
Defined in Hermod.Tracing.Types.Annotations | |
Instances
| FromJSON SeverityF | |
Defined in Hermod.Tracing.Types.Annotations | |
| ToJSON SeverityF | |
Defined in Hermod.Tracing.Types.Annotations Methods toEncoding :: SeverityF -> Encoding toJSONList :: [SeverityF] -> Value toEncodingList :: [SeverityF] -> Encoding | |
| Enum SeverityF | |
Defined in Hermod.Tracing.Types.Annotations Methods succ :: SeverityF -> SeverityF Source # pred :: SeverityF -> SeverityF Source # toEnum :: Int -> SeverityF Source # fromEnum :: SeverityF -> Int Source # enumFrom :: SeverityF -> [SeverityF] Source # enumFromThen :: SeverityF -> SeverityF -> [SeverityF] Source # enumFromTo :: SeverityF -> SeverityF -> [SeverityF] Source # enumFromThenTo :: SeverityF -> SeverityF -> SeverityF -> [SeverityF] Source # | |
| Show SeverityF | |
| Eq SeverityF | |
| Ord SeverityF | |
Defined in Hermod.Tracing.Types.Annotations | |
Instances
data BackendConfig #
Constructors
| Forwarder | |
| Stdout FormatLogging | |
| EKGBackend | |
| DatapointBackend | |
| PrometheusSimple Bool (Maybe HostName) PortNumber |
Instances
data ConfigOption #
Constructors
| ConfSeverity | |
| ConfDetail | |
Fields | |
| ConfBackend | |
Fields
| |
| ConfLimiter | |
Fields | |
Instances
data FormatLogging #
Constructors
| HumanFormatColoured | |
| HumanFormatUncoloured | |
| MachineFormat |
Instances
| Show FormatLogging | |
Defined in Hermod.Tracing.Types.Config | |
| Eq FormatLogging | |
Defined in Hermod.Tracing.Types.Config Methods (==) :: FormatLogging -> FormatLogging -> Bool Source # (/=) :: FormatLogging -> FormatLogging -> Bool Source # | |
| Ord FormatLogging | |
Defined in Hermod.Tracing.Types.Config Methods compare :: FormatLogging -> FormatLogging -> Ordering Source # (<) :: FormatLogging -> FormatLogging -> Bool Source # (<=) :: FormatLogging -> FormatLogging -> Bool Source # (>) :: FormatLogging -> FormatLogging -> Bool Source # (>=) :: FormatLogging -> FormatLogging -> Bool Source # max :: FormatLogging -> FormatLogging -> FormatLogging Source # min :: FormatLogging -> FormatLogging -> FormatLogging Source # | |
data ForwarderMode #
Instances
| FromJSON ForwarderMode | |
Defined in Hermod.Tracing.Types.Config | |
| Generic ForwarderMode | |
Defined in Hermod.Tracing.Types.Config Methods from :: ForwarderMode -> Rep ForwarderMode x Source # to :: Rep ForwarderMode x -> ForwarderMode Source # | |
| Show ForwarderMode | |
Defined in Hermod.Tracing.Types.Config | |
| Eq ForwarderMode | |
Defined in Hermod.Tracing.Types.Config Methods (==) :: ForwarderMode -> ForwarderMode -> Bool Source # (/=) :: ForwarderMode -> ForwarderMode -> Bool Source # | |
| Ord ForwarderMode | |
Defined in Hermod.Tracing.Types.Config Methods compare :: ForwarderMode -> ForwarderMode -> Ordering Source # (<) :: ForwarderMode -> ForwarderMode -> Bool Source # (<=) :: ForwarderMode -> ForwarderMode -> Bool Source # (>) :: ForwarderMode -> ForwarderMode -> Bool Source # (>=) :: ForwarderMode -> ForwarderMode -> Bool Source # max :: ForwarderMode -> ForwarderMode -> ForwarderMode Source # min :: ForwarderMode -> ForwarderMode -> ForwarderMode Source # | |
| type Rep ForwarderMode | |
Defined in Hermod.Tracing.Types.Config | |
data PrometheusSimpleRun #
Constructors
| PrometheusSimpleRun | |
Fields | |
Instances
data TraceConfig #
Constructors
| TraceConfig | |
Instances
| Show TraceConfig | |
Defined in Hermod.Tracing.Types.Config | |
data TraceOptionForwarder #
Constructors
| TraceOptionForwarder | |
Fields | |
Instances
Instances
| FromJSON Verbosity | |
Defined in Hermod.Tracing.Types.Config | |
| ToJSON Verbosity | |
Defined in Hermod.Tracing.Types.Config Methods toEncoding :: Verbosity -> Encoding toJSONList :: [Verbosity] -> Value toEncodingList :: [Verbosity] -> Encoding | |
| Generic Verbosity | |
| Show Verbosity | |
| Eq Verbosity | |
| Ord Verbosity | |
Defined in Hermod.Tracing.Types.Config | |
| type Rep Verbosity | |
Defined in Hermod.Tracing.Types.Config | |
data ConfigReflection #
Constructors
| ConfigReflection | |
newtype DocCollector #
Constructors
| DocCollector (IORef (Map Int LogDoc)) |
class LogFormatting a where #
Minimal complete definition
Methods
forMachine :: DetailLevel -> a -> Object #
Instances
| LogFormatting b => LogFormatting (Folding a b) | |
Defined in Hermod.Tracing.Types | |
Minimal complete definition
Methods
namespaceFor :: a -> Namespace a #
severityFor :: Namespace a -> Maybe a -> Maybe SeverityS #
privacyFor :: Namespace a -> Maybe a -> Maybe Privacy #
detailsFor :: Namespace a -> Maybe a -> Maybe DetailLevel #
documentFor :: Namespace a -> Maybe Text #
metricsDocFor :: Namespace a -> [(Text, Text)] #
allNamespaces :: [Namespace a] #
emptyLoggingContext :: LoggingContext #
getMetricName :: Metric -> Text #
nsGetComplete :: Namespace a -> [Text] #
nsGetTuple :: Namespace a -> ([Text], [Text]) #
nsPrependInner :: Text -> Namespace a -> Namespace b #
nsRawToText :: ([Text], [Text]) -> Text #
nsReplaceInner :: [Text] -> Namespace a -> Namespace a #
nsReplacePrefix :: [Text] -> Namespace a -> Namespace a #
emptyLogDoc :: Text -> [(Text, Text)] -> LogDoc #
contramapM :: Monad m => Trace m b -> (a -> m b) -> Trace m a Source #
Contramap a monadic function over a trace.
contramapMCond :: Monad m => Trace m b -> (a -> m (Maybe b)) -> Trace m a Source #
Like contramapM but can also filter out messages by returning Nothing.
foldTraceM :: forall a acc m. MonadUnliftIO m => (acc -> a -> m acc) -> acc -> Trace m (Folding a acc) -> m (Trace m a) Source #
Fold a monadic accumulator function over a trace.
Uses an MVar to hold the state.
foldCondTraceM :: forall a acc m. MonadUnliftIO m => (acc -> a -> m acc) -> acc -> (a -> Bool) -> Trace m (Folding a acc) -> m (Trace m a) Source #
Like foldTraceM but additionally filter the trace by a predicate.