| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Logging.Monitoring
Description
Provides Prometheus-based metrics server based on Tracer collection.
To add a new metric, one needs to:
- Add a field to
Metricsand register it inregisterMetrics, - Update the
monitorfunction to handle relevantHydraLogentries and update the underlying Prometheus metric. Nested helpers are provided to increase aCounterby one (tick) and toobservesome value in aHistogram.
The metric handles are typed, so a metric can only be updated in the way it was registered and a name can only be referred to if it was registered.
Synopsis
- withMonitoring :: (MonadIO m, MonadAsync m, IsTx tx, MonadMonotonicTime m, MonadTime m, MonadLabelledSTM m) => Maybe PortNumber -> Tracer m (HydraLog tx) -> (Tracer m (HydraLog tx) -> m ()) -> m ()
Documentation
withMonitoring :: (MonadIO m, MonadAsync m, IsTx tx, MonadMonotonicTime m, MonadTime m, MonadLabelledSTM m) => Maybe PortNumber -> Tracer m (HydraLog tx) -> (Tracer m (HydraLog tx) -> m ()) -> m () Source #
Wraps a monadic action using a Tracer and capture metrics based on traces.
Given a portNumber, this wrapper starts a Prometheus-compliant server on this port.
This is a no-op if given Nothing. This function is not polymorphic over the type of
messages because it needs to understand them in order to provide meaningful metrics.