import type { Tracer } from '../types/observability.js'; type SpanAttrValue = string | number | boolean; interface RecordedSpan { traceId: string; spanId: string; name: string; startTimeUnixNano: bigint; endTimeUnixNano?: bigint | undefined; attributes: Record; status: { code: number; message?: string | undefined; }; } export interface OtlpTraceExporterOptions { /** OTLP HTTP endpoint base URL. `/v1/traces` is appended unless already present. */ endpoint: string; /** Push interval in milliseconds. Defaults to 5s (traces are bursty). */ intervalMs?: number | undefined; /** Hard cap on buffered spans. When exceeded, oldest are dropped. Defaults to 2048. */ maxBufferedSpans?: number | undefined; /** Authorization header. */ authorization?: string | undefined; /** Extra request headers. */ headers?: Record; /** Resource attributes. Defaults to `service.name=wrongstack`. */ resourceAttributes?: Record; /** Instrumentation scope name. Default `wrongstack`. */ scopeName?: string | undefined; /** Per-request timeout in ms. Default 10s. */ timeoutMs?: number | undefined; /** Override fetch (for tests). */ fetchImpl?: typeof globalThis.fetch | undefined; /** Called on push failure. Defaults to silent. */ onError?: ((err: unknown) => void) | undefined; } export interface OtlpTraceExporterHandle { /** The Tracer to install on Agent / ToolExecutor. */ readonly tracer: Tracer; /** Push buffered spans immediately. */ flush(): Promise; /** Stop the timer, push remaining spans, resolve. */ stop(): Promise; /** Test helper: snapshot of spans currently in the buffer (not yet pushed). */ readonly buffered: () => readonly RecordedSpan[]; } interface OtlpAttribute { key: string; value: { stringValue: string; } | { boolValue: boolean; } | { doubleValue: number; } | { intValue: string; }; } interface OtlpSpan { traceId: string; spanId: string; name: string; kind: 1; startTimeUnixNano: string; endTimeUnixNano: string; attributes: OtlpAttribute[]; status: { code: number; message?: string | undefined; }; } interface OtlpTracesRequest { resourceSpans: { resource: { attributes: OtlpAttribute[]; }; scopeSpans: { scope: { name: string; }; spans: OtlpSpan[]; }[]; }[]; } export declare function buildOtlpTracesRequest(spans: readonly RecordedSpan[], opts?: { resourceAttributes?: Record; scopeName?: string | undefined; }): OtlpTracesRequest; /** * Start the OTLP trace exporter. Returns a `Tracer` to install on the * runtime (`Agent.run` etc.) and `flush()`/`stop()` controls. */ export declare function startOtlpTraceExporter(opts: OtlpTraceExporterOptions): OtlpTraceExporterHandle; export {}; //# sourceMappingURL=otlp-traces.d.ts.map