ecluse:ecluse-runtime
Safe HaskellNone
LanguageGHC2021

Ecluse.Runtime.Telemetry.Correlation

Description

The log-to-trace correlation glue: read the active OpenTelemetry span off the ambient context and stamp its ids onto the dd log object (Ecluse.Runtime.Log), so a reader joins a JSONL line to the trace it was emitted within. This is the IO half Ecluse.Runtime.Log defers, which is why that module needs no OpenTelemetry dependency. The ids take hs-opentelemetry-propagator-datadog's form: the unsigned decimal of the low 64 bits, big-endian. No span in scope, or one whose context is not valid, contributes no ids, so a line never carries a meaningless all-zero trace id. The identity still stamps it.

Synopsis

Identity

ddIdentity :: ResolvedTelemetry -> DdContext Source #

The span-less dd identity that stamps every log line. ddPayloadNow fills the span at log time. The one resolved configuration feeds the SDK too, so logs and traces share an identity.

ddIdentityFromEnvironment :: IO DdContext Source #

Resolve the dd identity from the environment on Ecluse.Runtime.Telemetry.Resolve's precedence, so the log identity matches the exporter's. Call once at composition, never per line.

Active-span correlation

ddPayloadNow :: MonadIO m => DdContext -> m SimpleLogPayload Source #

The dd object for the current log site as a katip payload. Install it as a request or worker scope's initial context so every line under that scope carries dd.