hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

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 Metrics and register it in registerMetrics,
  • Update the monitor function to handle relevant HydraLog entries and update the underlying Prometheus metric. Nested helpers are provided to increase a Counter by one (tick) and to observe some value in a Histogram.

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

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.