/** * W3C Trace Context provider. * * Reads the consumer's currently-active OTel `Context` and serializes the * active span's `SpanContext` into a W3C `traceparent` header value * (`00---`). The `tracestate` arm carries any * vendor-specific propagation data attached upstream. * * Without an `OTelAPI` (or with an OTel API but no active recording span), the * provider falls back to the per-envelope filler — a fresh, valid 55-char * `traceparent` per call. The QAR server tolerates the synthetic value; what it * doesn't tolerate is an empty string (the schema enforces the regex). */ import type { OTelAPI } from '../tracing/types.js'; /** Concrete `trace_context` value the SDK writes onto every outbound envelope. */ export interface TraceContextValue { /** Always present, always 55 chars (`00-<32hex>-<16hex>-<2hex>`). */ readonly traceparent: string; /** Optional, only when the active context has a non-empty tracestate. */ readonly tracestate?: string; } /** Build a W3C `traceparent` from the components of a SpanContext. */ export declare function formatTraceparent(traceId: string, spanId: string, traceFlags: number): string; /** * Provider for the per-envelope `trace_context`. Stateless — every call reads * the live OTel context anew. Cheap; no caching needed (a hot envelope path * does ~1 read per send). */ export declare class TraceContextProvider { private readonly otel; /** * @param otel Optional OTel API. When `undefined`, every `current()` call * returns a fresh random traceparent. */ constructor(otel: OTelAPI | undefined); /** * The wire `trace_context` for an outbound envelope — always a valid value. * * Returns {@link active}'s resolved SpanContext when a recording span is * live (stitching the envelope into the consumer's trace), otherwise a fresh * random 55-char filler. This is the WS arm: the envelope schema requires a * non-empty `trace_context` on every send, so there's no "omit" option here. */ current(): TraceContextValue; /** * Resolve the active SpanContext, or `undefined` when there's no real * recording span to propagate. * * This is the HTTP-header arm: unlike the WS envelope (whose schema requires * a `trace_context` on every send, hence {@link current}'s filler fallback), * an outbound HTTP request has no such requirement. Returning `undefined` * lets the caller omit `traceparent` entirely when OTel isn't active — * fabricating a fresh random trace that continues nowhere is just noise on * the HTTP path. */ active(): TraceContextValue | undefined; /** The currently-active recording span, or `undefined` if no OTel / no span. */ private activeSpan; } //# sourceMappingURL=traceContext.d.ts.map