Normandy.Telemetry.OtelCtx (normandy v0.6.2)

View Source

Soft OpenTelemetry context propagation across process boundaries.

Normandy doesn't depend on :opentelemetry directly — consumers wire it up via telemetry handlers. When OTel is loaded, capture/0 snapshots the active context in the calling process so a spawned process can restore/1 it; spans created in the spawned process then nest under the parent's active span instead of becoming root spans in their own trace. When OTel is not loaded, both functions are cheap no-ops.

Usage

parent_ctx = Normandy.Telemetry.OtelCtx.capture()

Task.async(fn ->
  Normandy.Telemetry.OtelCtx.restore(parent_ctx)
  # ... spans opened here nest under the parent's active span
end)

Summary

Functions

capture()

@spec capture() :: term() | nil

restore(ctx)

@spec restore(term() | nil) :: :ok