| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Runtime.Telemetry
Description
The OpenTelemetry substrate: the tracer and meter providers the rest of the proxy hangs
spans and metrics on, behind the ECLUSE_OBSERVABILITY__TELEMETRY master switch. Observability
is opt-in, so with that switch unset nothing is wired and the SDK is never initialised.
withTelemetry is the lifecycle bracket the composition root runs the proxy within: it builds
the providers from the standard OTEL_* variables, runs the Prometheus scrape listener, and
tears both down along every exit path. It also wraps the OTLP exporters, because
hs-opentelemetry 1.0.0.0 drops a failed export silently.
Synopsis
- data TelemetrySwitch
- parseTelemetrySwitch :: Text -> Either Text TelemetrySwitch
- data Telemetry
- telemetryDisabled :: Telemetry
- telemetryTracerProvider :: Telemetry -> Maybe TracerProvider
- telemetryMeterProvider :: Telemetry -> Maybe MeterProvider
- withTelemetry :: TelemetrySwitch -> LogEnv -> (Telemetry -> IO a) -> IO a
Master switch
data TelemetrySwitch Source #
The ECLUSE_OBSERVABILITY__TELEMETRY master switch. Telemetry is opt-in, so
TelemetryOff is the default.
Constructors
| TelemetryOff | Telemetry is disabled (the default): nothing is wired and nothing is emitted. |
| TelemetryOn | Telemetry is enabled: the SDK providers are built from the standard
|
Instances
| WireVocab TelemetrySwitch Source # | |||||
Defined in Ecluse.Runtime.Telemetry.Internal | |||||
| Generic TelemetrySwitch Source # | |||||
Defined in Ecluse.Runtime.Telemetry.Internal Associated Types
Methods from :: TelemetrySwitch -> Rep TelemetrySwitch x # to :: Rep TelemetrySwitch x -> TelemetrySwitch # | |||||
| Show TelemetrySwitch Source # | |||||
Defined in Ecluse.Runtime.Telemetry.Internal Methods showsPrec :: Int -> TelemetrySwitch -> ShowS # show :: TelemetrySwitch -> String # showList :: [TelemetrySwitch] -> ShowS # | |||||
| Eq TelemetrySwitch Source # | |||||
Defined in Ecluse.Runtime.Telemetry.Internal Methods (==) :: TelemetrySwitch -> TelemetrySwitch -> Bool # (/=) :: TelemetrySwitch -> TelemetrySwitch -> Bool # | |||||
| Universe TelemetrySwitch Source # | |||||
Defined in Ecluse.Runtime.Telemetry.Internal Methods universe :: [TelemetrySwitch] # | |||||
| type Rep TelemetrySwitch Source # | |||||
Defined in Ecluse.Runtime.Telemetry.Internal | |||||
parseTelemetrySwitch :: Text -> Either Text TelemetrySwitch Source #
Parse a TelemetrySwitch from its wire name. An unrecognised value fails loudly with the
accepted set, never falling back to a mode.
>>>parseTelemetrySwitch "off"Right TelemetryOff
>>>parseTelemetrySwitch "on"Right TelemetryOn
>>>parseTelemetrySwitch "maybe"Left "unknown telemetry switch \"maybe\" (expected one of: on, off)"
The telemetry handle
The telemetry handle held in the composition root: the off-by-default no-op or the enabled providers. The disabled case carries no provider, so telemetry is inert rather than unsampled.
telemetryDisabled :: Telemetry Source #
The disabled telemetry handle: the off-by-default no-op that holds no providers
and emits nothing. This is what an unset ECLUSE_OBSERVABILITY__TELEMETRY resolves to.
telemetryMeterProvider :: Telemetry -> Maybe MeterProvider Source #
The meter provider a Telemetry handle exposes, Nothing when telemetry is
disabled (the dual of telemetryTracerProvider for metric instruments).
Lifecycle
withTelemetry :: TelemetrySwitch -> LogEnv -> (Telemetry -> IO a) -> IO a Source #
Run an action with a Telemetry handle bracketed by the TelemetrySwitch. TelemetryOff
opens nothing. TelemetryOn builds the providers, runs the scrape listener, and tears both down.