| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Telemetry.Reporters
Description
The bridge from the telemetry-agnostic reporters the pre-telemetry providers carry
to the live ecluse.* instruments — and the deferral that lets a provider built before
the meter exists record once it does.
The circuit breaker (Ecluse.Breaker) and the refreshing credential provider
(Ecluse.Credential.Refresh) are constructed at boot before the telemetry substrate
(the meter provider) exists, so they cannot be handed a Metrics at construction. Each
instead carries a small, telemetry-agnostic reporter callback. This module supplies those
callbacks, backed by a DeferredMetrics cell: inert (recording nothing) until the
composition root has built the instruments and called installMetrics, live
thereafter. That mirrors the no-op-meter discipline of Ecluse.Telemetry.Instruments:
once installed, an inert handle (built on the SDK's no-op meter when telemetry is off)
still discards every measurement, so the providers record unconditionally either way.
The catalogue and the cardinality rule are described in
docs/architecture/observability.md.
Synopsis
- data DeferredMetrics
- newDeferredMetrics :: IO DeferredMetrics
- installMetrics :: DeferredMetrics -> Metrics -> IO ()
- deferredBreakerReporter :: DeferredMetrics -> BreakerSource -> BreakerReporter
- deferredRefreshReporter :: DeferredMetrics -> Provider -> RefreshReporter
- breakerStateOf :: Breaker -> BreakerState
Deferred metric handle
data DeferredMetrics Source #
A Metrics handle that may not exist yet: empty until the telemetry substrate has
built the instruments, then live. The pre-telemetry boot phase builds providers that
record through reporters closed over this, so they can be wired before the meter exists
and become live once it does. A record through it while empty is a no-op.
newDeferredMetrics :: IO DeferredMetrics Source #
A fresh, empty DeferredMetrics: every reporter over it is inert until installMetrics.
installMetrics :: DeferredMetrics -> Metrics -> IO () Source #
Install the live instruments, making every reporter over this handle record through
them from now on. Called once by the composition root after newMetrics has built the
instruments (which are themselves inert when telemetry is off).
Reporters over the deferred handle
deferredBreakerReporter :: DeferredMetrics -> BreakerSource -> BreakerReporter Source #
A BreakerReporter that records a breaker's state to ecluse.rule.breaker.state
under the given source, through the deferred handle (inert until it is installed).
deferredRefreshReporter :: DeferredMetrics -> Provider -> RefreshReporter Source #
A RefreshReporter that records each refresh outcome to ecluse.credential.refresh
(by result) and the reported remaining lifetime to ecluse.credential.token.ttl.seconds,
both under the given provider, through the deferred handle (inert until it is installed).
Breaker-state projection
breakerStateOf :: Breaker -> BreakerState Source #
Project the breaker's runtime state (Ecluse.Breaker) onto the bounded gauge value
the catalogue records (Ecluse.Telemetry.Metrics). The consecutive-failure tally a
Closed breaker carries is not observable, so it collapses to the single closed value.