import { Context } from "@opentelemetry/api"; import { SpanProcessor, ReadableSpan, Span } from "@opentelemetry/sdk-trace-base"; import type { AdvancedOptions } from "../types.js"; export interface IntrospectionSpanProcessorOptions { /** Authentication token (env: INTROSPECTION_TOKEN) */ token?: string; /** * Service name for telemetry (env: INTROSPECTION_SERVICE_NAME). * Note: For spans, the service name is typically set on the TracerProvider's resource. * This option is provided for consistency but the TracerProvider's resource takes precedence. */ serviceName?: string; /** Advanced options for configuration and testing */ advanced?: AdvancedOptions; } /** * OTel {@link SpanProcessor} that forwards traces to the Introspection backend * via OTLP, stamping baggage-derived identity onto each Gen AI * semantic convention attributes. * * Processors are constructor-only in OTel SDK v2 — there is no post-hoc * `addSpanProcessor` — so pass it when you build the provider. * * @example * ```ts * import { IntrospectionSpanProcessor } from "@introspection-sdk/introspection-node/otel"; * import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node"; * * const provider = new NodeTracerProvider({ * spanProcessors: [new IntrospectionSpanProcessor({ token: "intro_…" })], * }); * provider.register(); * ``` */ export declare class IntrospectionSpanProcessor implements SpanProcessor { private _spanProcessor; private _serviceName?; /** * Fallback conversation id per trace, so spans in one trace agree when no * conversation is set. Bounded and FIFO-evicted: one entry per trace in a * long-lived process is a slow leak, and traces are short-lived, so the * oldest entry is the one least likely to still be receiving spans. */ private _conversationIds; private static readonly MAX_TRACKED_TRACES; constructor(options?: IntrospectionSpanProcessorOptions); /** * Called when a new span is started; delegates to the inner batch processor. * * @param span - The span that was just started. * @param parentContext - The parent {@link Context}. */ onStart(span: Span, parentContext: Context): void; /** * Called when a span ends. If the span * instrumentor, its attributes are converted to `gen_ai.*` semconv keys * before being forwarded. * * @param span - The completed {@link ReadableSpan}. */ onEnd(span: ReadableSpan): void; /** * Shut down the inner batch processor and its exporter. * * @returns A promise that resolves once all pending spans are flushed. */ shutdown(): Promise; /** * Force-flush any buffered spans to the Introspection backend. * * @returns A promise that resolves once the flush completes. */ forceFlush(): Promise; } //# sourceMappingURL=span-processor.d.ts.map