UNPKG

autotel

Version:
40 lines (39 loc) 1.52 kB
import { ReadableSpan, SpanExporter } from "@opentelemetry/sdk-trace-base"; //#region src/test-span-collector.d.ts /** Attribute value types that survive serialization */ type SerializableValue = string | number | boolean | string[] | number[] | boolean[]; /** * Portable serialized span for embedding in test metadata. * `startTimeMs` is derived from OTel HrTime — epoch-based wall-clock ms in the current SDK. * * Defined as a `type` (not `interface`) so it is assignable to * `Record<string, unknown>` in TypeScript 6+ strict mode. */ type SerializedSpan = { spanId: string; parentSpanId?: string; name: string; startTimeMs: number; durationMs: number; status: 'ok' | 'error' | 'unset'; statusMessage?: string; attributes?: Record<string, SerializableValue>; }; declare class TestSpanCollector implements SpanExporter { private traces; export(spans: ReadableSpan[], callback: (result: { code: number; }) => void): void; /** * Drain and serialize spans that are descendants of `rootSpanId` within `traceId`. * Filters to the subtree rooted at the test span to prevent cross-test mixing. * Removes the entire traceId entry from the collector. */ drainTrace(traceId: string, rootSpanId: string): SerializedSpan[]; shutdown(): Promise<void>; forceFlush(): Promise<void>; } declare function serializeSpan(span: ReadableSpan): SerializedSpan; //#endregion export { SerializedSpan, TestSpanCollector, serializeSpan }; //# sourceMappingURL=test-span-collector.d.ts.map