/************************** * OpenTelemetry OTLP Setup * * Thin wrapper that delegates to the `ext-observability-opentelemetry` extension via the * `TracingExporter` contract. When the extension is not installed, all span * operations silently no-op. * * Reads configuration from environment variables: * - OTEL_TRACES_ENABLED: "true" to enable tracing * - OTEL_SERVICE_NAME: Service name for traces * - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint * - OTEL_EXPORTER_OTLP_HEADERS: Auth headers **************************/ import { type AttributeValue, type Context, type Link, type Span, SpanKind } from "./api-shim.js"; /** Configuration used by otlpconfig. */ export interface OTLPConfig { serviceName: string; endpoint: string; headers?: Record; enabled: boolean; } /** Initialize OTLP tracing export. */ export declare function initializeOTLP(): Promise; /** Shut down OTLP tracing export. */ export declare function shutdownOTLP(): Promise; /** Check whether OTLP export is enabled. */ export declare function isOTLPEnabled(): boolean; /** Initialize OTLP tracing with explicit API adapters. */ export declare function initializeOTLPWithApis(): Promise; export type WithSpanOptions = { kind?: SpanKind; /** * Maps a thrown error to what the span should report. Supply this to say * something more useful than the default classification, for example naming * the node that failed. Return the error itself to opt a span back into the * raw message text and the stack trace that goes with it; anything else you * return is reported without a stack, since its frames would describe your * mapper rather than the failure. */ errorStatus?: (error: unknown) => unknown; /** * Causal relationships to spans that are not this span's parent. Use for work * whose cause is real but whose lifetime is independent of it. */ links?: Link[]; /** * Start a new trace instead of continuing the caller's. Durable work wants * this: a child inherits the caller's sampling decision, so a sampled-out * caller would otherwise drop the whole thing, and work that outlives the * caller leaves an open span inside a finished trace. Pair it with a link * back to the caller so the causal edge survives. */ root?: boolean; }; /** Applies span. */ export declare function withSpan(name: string, fn: (span: Span) => Promise, attributes?: Record, options?: WithSpanOptions): Promise; /** Applies span sync. */ export declare function withSpanSync(name: string, fn: () => T, attributes?: Record, options?: WithSpanOptions): T; /** Context for extract. */ export declare function extractContext(headers: Headers): Context | undefined; /** Context for inject. */ export declare function injectContext(headers: Headers): void; /** Starts server span. */ export declare function startServerSpan(method: string, path: string, parentContext?: unknown): { span: Span; context: Context; } | null; /** End an active server tracing span. */ export declare function endServerSpan(span: unknown, statusCode: number, error?: Error): void; /** Sets span attributes. */ export declare function setSpanAttributes(span: unknown, attributes: Record): void; /** Adds an event to a span. */ export declare function addSpanEvent(span: unknown, name: string, attributes?: Record): void; /** Sets active span attributes. */ export declare function setActiveSpanAttributes(attributes: Record): void; /** Records an event on the currently active span, if there is one. */ export declare function addActiveSpanEvent(name: string, attributes?: Record): void; /** * Marks the active span as failed. * * The error names the failure, it does not carry it: this is called from the * code that noticed the problem, so a stack captured here describes the * reporting site. It is reported without one. */ export declare function setActiveSpanErrorStatus(error: unknown): void; /** Context for with. */ export declare function withContext(spanContext: unknown, fn: () => Promise): Promise; /** Context for get trace. */ /** * The active span's identity as a `traceparent`, for storing somewhere durable. * * Undefined when nothing is tracing, so a caller persists a linkable identity * or none at all -- never a placeholder that resolves to no span. */ export declare function getActiveTraceparent(): string | undefined; /** * Build a span link from a `traceparent` read back out of durable storage. * * Returns undefined for anything unparseable, so a corrupted or absent record * costs the link and nothing else. */ export declare function traceparentLink(traceparent: string | undefined, attributes?: Record): Link | undefined; /** A link to the span that is active right now, for a span about to be rooted away from it. */ export declare function activeSpanLink(attributes?: Record): Link | undefined; export declare function getTraceContext(): { traceId?: string; spanId?: string; }; //# sourceMappingURL=otlp-setup.d.ts.map