Skip to content

instrumentTracing

instrumentTracing(client, options): () => void

Defined in: src/otel/index.ts:61

Traces every request the client makes: one INTERNAL span per ticket, covering queueing, every attempt and backoff, with one CLIENT child span per attempt (http.request.resend_count is the retry number). Attributes follow the OpenTelemetry HTTP semantic conventions.

Call it after your own client.use() middleware: the attempt span is registered as middleware, and the last one registered runs closest to fetch, so it times the request itself and injects headers last.

Returns a function that stops recording. The middleware stays registered (middleware can’t be removed) but becomes a pass-through.

HttpClient

OtelTracingOptions

() => void

import { trace } from "@opentelemetry/api";
const stop = instrumentTracing(client, { tracer: trace.getTracer("checkout") });