ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

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

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 OTEL_* environment and the OTLP exporter is active.

Instances

Instances details
WireVocab TelemetrySwitch Source # 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

Generic TelemetrySwitch Source # 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

Associated Types

type Rep TelemetrySwitch 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

type Rep TelemetrySwitch = D1 ('MetaData "TelemetrySwitch" "Ecluse.Runtime.Telemetry.Internal" "ecluse-0.4.0-inplace-ecluse-runtime" 'False) (C1 ('MetaCons "TelemetryOff" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TelemetryOn" 'PrefixI 'False) (U1 :: Type -> Type))
Show TelemetrySwitch Source # 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

Eq TelemetrySwitch Source # 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

Universe TelemetrySwitch Source # 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

type Rep TelemetrySwitch Source # 
Instance details

Defined in Ecluse.Runtime.Telemetry.Internal

type Rep TelemetrySwitch = D1 ('MetaData "TelemetrySwitch" "Ecluse.Runtime.Telemetry.Internal" "ecluse-0.4.0-inplace-ecluse-runtime" 'False) (C1 ('MetaCons "TelemetryOff" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TelemetryOn" 'PrefixI 'False) (U1 :: Type -> Type))

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

data Telemetry Source #

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.

telemetryTracerProvider :: Telemetry -> Maybe TracerProvider Source #

The tracer provider a Telemetry handle exposes, Nothing when telemetry is disabled. Nothing means emit nothing, never fabricate a no-op provider at the edge.

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.