ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Telemetry.Internal

Description

The provider construction, the lifecycle bracket and the exporter wrappers behind Ecluse.Runtime.Telemetry, which documents the substrate and re-exports the curated surface. Importing this module opts out of that stability promise, the convention text and bytestring use, so production code imports the public one.

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.

Constructors

TelemetryDisabled

The off-by-default no-op: no providers, nothing emitted.

TelemetryEnabled TelemetryProviders

The enabled handle carrying the SDK's providers, built from the standard OTEL_* environment. The providers live in a TelemetryProviders product so neither field is a partial record selector on this sum.

data TelemetryProviders Source #

The SDK providers an enabled Telemetry handle carries: a total product, so its fields are not partial selectors over the Telemetry sum.

Constructors

TelemetryProviders 

Fields

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.

telemetryEnabled :: OTelSignals -> Telemetry Source #

Build an enabled telemetry handle from the SDK signals withTelemetry brackets.

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.

Export-failure observation (exporter wrappers)