/**** * OpenTelemetry OTLP tracing for proxy. * * The standalone proxy (split mode) does not run the server bootstrap, so it * wires the OTLP SDK itself: it loads ext-observability-opentelemetry, starts * its `OtlpTracingExporter`, and registers the SDK provider with the core * api-shim BEFORE caching a tracer. Without this wiring the shim only ever * hands out no-op tracers and nothing is exported (issue #2723). * * Env: OTEL_TRACES_ENABLED, OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT, * OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS * (endpoint/headers are consumed by the extension itself.) */ import { type Context, type Span } from "../observability/tracing/api-shim.js"; import type { TracingExporter } from "../extensions/observability/tracing-exporter.js"; export type OtlpGateResult = { ok: true; } | { ok: false; reason: string; }; /** * Decide whether OTLP tracing should be initialized for this process. * Pure so the decision (and its logged reason) is unit-testable. */ export declare function resolveOtlpGate(config: { enabled: boolean; endpoint: string; }): OtlpGateResult; /** * Initialize OTLP tracing for the standalone proxy. * * Loads ext-observability-opentelemetry, starts its exporter, wires the SDK * provider (plus metrics API and active-span accessor) into the core shim, * and only then caches a tracer. Logs `[otel] Initialized` only when a real * provider is wired; otherwise logs why tracing is disabled. Never throws. * * @param loadExporter Test seam; production callers use the default loader. */ export declare function initializeOTLPWithApis(loadExporter?: () => Promise): Promise; /** Flush pending spans and release the exporter. Safe to call when disabled. */ export declare function shutdownOTLP(): Promise; /** Reset module state between tests. Mirrors api-shim's `_resetShimForTests`. */ export declare function _resetOTLPForTests(): void; export declare function extractContext(headers: Headers): Context | undefined; export declare function injectContext(headers: Headers): void; export declare function startServerSpan(method: string, path: string, parentContext?: Context): { span: Span; context: Context; } | null; export declare function endSpan(span: Span | undefined, statusCode: number, error?: Error): void; export declare function withContext(spanContext: Context, fn: () => Promise): Promise; export declare function getTraceContext(): { traceId?: string; spanId?: string; }; /** * Span names for proxy tracing. */ export declare const ProxySpanNames: { readonly PROXY_TOKEN_FETCH: "proxy.token_fetch"; readonly PROXY_DOMAIN_LOOKUP: "proxy.domain_lookup"; readonly OAUTH_TOKEN_REQUEST: "oauth.token_request"; readonly HTTP_CLIENT_FETCH: "http.client.fetch"; }; /** * Execute an async function within a tracing span. * If tracing is disabled, executes the function directly. */ export declare function withSpan(name: string, fn: () => Promise, attributes?: Record): Promise; //# sourceMappingURL=tracing.d.ts.map