/** * OpenTelemetry instrumentation for eval-kit. * * Uses dynamic import so @opentelemetry/api is an optional peer dependency. * When the package is not installed or no SDK is configured, all tracing * operations are no-ops with zero overhead. */ interface SpanAttributes { [key: string]: string | number | boolean | undefined; } /** * Minimal span interface matching the subset of @opentelemetry/api Span we use. */ export interface EvalKitSpan { setAttribute(key: string, value: string | number | boolean): void; setStatus(status: { code: number; message?: string; }): void; recordException(error: Error | string): void; addEvent(name: string, attributes?: SpanAttributes): void; end(): void; } interface Tracer { startActiveSpan(name: string, options: { attributes?: SpanAttributes; }, fn: (span: EvalKitSpan) => T): T; } /** * Enable or disable eval-kit's OpenTelemetry instrumentation globally. * * When disabled, all tracing functions return no-ops — identical to the * behaviour when `@opentelemetry/api` is not installed. This lets you * use OTel in your application without eval-kit emitting spans. * * Telemetry is **disabled** by default. */ export declare function enableTelemetry(enabled: boolean): void; /** * Returns the current telemetry enabled state. */ export declare function isTelemetryEnabled(): boolean; export declare const SpanStatusCode: { readonly UNSET: 0; readonly OK: 1; readonly ERROR: 2; }; /** * Get the eval-kit tracer (async). Triggers resolution on first call. * Returns the no-op tracer when telemetry is disabled. */ export declare function getTracer(): Promise; /** * Get the cached tracer synchronously. Returns no-op if the tracer * hasn't been resolved yet (i.e., no prior withSpan/getTracer call) * or if telemetry is disabled. */ export declare function getCachedTracer(): Tracer; export interface WithSpanOptions { attributes?: SpanAttributes; } /** * Wrap an async operation with an OpenTelemetry span. * * - Creates a child span under the current active span (if any) * - Sets initial attributes from options * - On success: sets status OK, ends span * - On error: records exception, sets status ERROR, ends span, re-throws * - The callback receives the span so it can add attributes/events during execution */ export declare function withSpan(name: string, options: WithSpanOptions, fn: (span: EvalKitSpan) => Promise): Promise; /** * Reset the cached tracer. Only used in tests. */ export declare function _resetTracer(): void; export {}; //# sourceMappingURL=telemetry.d.ts.map