/** * The one place runtime code touches the OTel trace API: manual spans are created * exclusively through {@link withSpan}. Vendor-neutral (depends only on * `@opentelemetry/api`); the SDK itself is stood up in `otel-sdk.ts`. When the SDK * is not initialised (telemetry off, or under test) the API resolves a no-op tracer, * so `withSpan` runs the callback with near-zero overhead — no `enabled` gate needed. */ import { type Span, type SpanKind, type Attributes, type Tracer } from "@opentelemetry/api"; /** The single tracer for our manual spans. Resolves the no-op tracer pre-init. */ export declare function getTracer(): Tracer; /** * Run `fn` inside a new active span, standardising the lifecycle: * * - `startActiveSpan`, so the span is the active context: auto-instrumented HTTP * children and nested {@link withSpan} calls nest under it while work stays on the * synchronous `await` chain. (`startSpan` would detach children into roots.) * - Passes the span **handle** into `fn` — use it for `addEvent`/`setAttribute`/ * `recordException`, never `trace.getActiveSpan()` (ambiguous under concurrent * sibling spans, e.g. a `Promise.all` fan-out). * - On throw: records the exception, sets ERROR status, then **rethrows** — tracing * observes, never alters control flow. Pass `options.expected` to mark control-flow * throws (e.g. `SkipScan`) that should propagate *without* painting the span red. * - Always ends the span (`finally`), so a span can never leak. * * Tracing must never break runtime code: the span operations are guarded so a throw * from the SDK — or from a caller's `expected` predicate — can neither mask `fn`'s * error nor corrupt its result. */ export declare function withSpan(name: string, attributes: Attributes, fn: (span: Span) => Promise, options?: { expected?: (err: unknown) => boolean; kind?: SpanKind; }): Promise; /** * The synchronous half of {@link withSpan} — same tracer, same lifecycle, for a section that never * awaits. It exists because `withSpan` always hands back a promise, and a `setInterval` tick has * nowhere to put one: floating it turns a throw into an unhandled rejection instead of an error the * caller sees, and awaiting it would make a synchronous tick asynchronous for no reason. * * No `expected` option: the callers are ticks, where there is no control-flow throw to spare. */ export declare function withSpanSync(name: string, attributes: Attributes, fn: (span: Span) => T): T; //# sourceMappingURL=tracing.d.ts.map