Skip to content
Buy me a coffee

instrumentOpenTelemetry

instrumentOpenTelemetry(options?): () => void

Defined in: src/otel.ts:51

Exports every pipeline’s telemetry to OpenTelemetry.

Traces: span resilience.pipeline <name> per execution, with a child resilience.attempt span per call of the callback (made active, so spans you start in the callback nest under it). Failures set ERROR status and record the exception; strategy events (retry, timeout, circuit rejected…) are added as span events. Nesting needs a context manager, which every OTel Node SDK registers.

Metrics:

  • resilience.strategy.events (counter): retries, timeouts, circuit transitions, rejections…
  • resilience.pipeline.duration (histogram, s): one sample per execution, with outcome and error.type.
  • resilience.attempt.duration (histogram, s): one sample per attempt of a retry strategy, with attempt.number (capped at 10: 10 means the 10th retry or later), outcome, error.type. Emitted for every attempt (any pipeline). Its count is the number of attempts.
  • resilience.circuit.state (gauge): 0 closed, 1 half-open, 2 open, 3 isolated, per pipeline.name + strategy.name (the 1000 most recently changed circuits).

Call once at startup; returns a function that stops it.

OpenTelemetryOptions = {}

() => void