/** * Span attributes */ export type SpanAttributes = Record; /** * Span status */ export declare enum SpanStatus { OK = "OK", ERROR = "ERROR", UNSET = "UNSET" } /** * Span context for distributed tracing */ export interface SpanContext { traceId: string; spanId: string; traceFlags: number; traceState?: string; } /** * Span interface */ export interface Span { /** Span name */ name: string; /** Span start time */ startTime: Date; /** Span end time (if ended) */ endTime?: Date; /** Span status */ status: SpanStatus; /** Span attributes */ attributes: SpanAttributes; /** Span context */ context: SpanContext; /** Parent span ID */ parentSpanId?: string; /** Set an attribute */ setAttribute(key: string, value: string | number | boolean): void; /** Set multiple attributes */ setAttributes(attributes: SpanAttributes): void; /** Set span status */ setStatus(status: SpanStatus, message?: string): void; /** Add an event to the span */ addEvent(name: string, attributes?: SpanAttributes): void; /** End the span */ end(): void; /** Record an exception */ recordException(exception: Error): void; } /** * Tracer interface */ export interface Tracer { /** Start a new span */ startSpan(name: string, attributes?: SpanAttributes): Span; /** Get the active span */ getActiveSpan(): Span | null; /** Execute function within span context */ withSpan(name: string, fn: (span: Span) => Promise): Promise; } /** * Basic in-memory span implementation */ export declare class InMemorySpan implements Span { name: string; startTime: Date; endTime?: Date; status: SpanStatus; attributes: SpanAttributes; context: SpanContext; parentSpanId?: string; events: Array<{ name: string; timestamp: Date; attributes?: SpanAttributes; }>; constructor(name: string, attributes?: SpanAttributes, parentContext?: SpanContext); setAttribute(key: string, value: string | number | boolean): void; setAttributes(attributes: SpanAttributes): void; setStatus(status: SpanStatus, message?: string): void; addEvent(name: string, attributes?: SpanAttributes): void; recordException(exception: Error): void; end(): void; /** * Get duration in milliseconds */ getDuration(): number | null; /** * Convert span to JSON */ toJSON(): Record; } /** * Span exporter interface */ export interface SpanExporter { export(spans: Span[]): void | Promise; } /** * Console span exporter for debugging */ export declare class ConsoleSpanExporter implements SpanExporter { export(spans: Span[]): void; } /** * In-memory tracer implementation */ export declare class InMemoryTracer implements Tracer { private activeSpan; private spans; private exporter; constructor(exporter?: SpanExporter); startSpan(name: string, attributes?: SpanAttributes): Span; getActiveSpan(): Span | null; withSpan(name: string, fn: (span: Span) => Promise): Promise; private exportSpan; /** * Get all recorded spans */ getSpans(): Span[]; /** * Clear all spans */ clear(): void; /** * Create context carrier for propagation */ inject(carrier: Record): void; /** * Extract context from carrier */ extract(carrier: Record): SpanContext | null; } /** * Default tracer instance */ export declare const defaultTracer: Tracer; /** * No-op tracer instance (for performance-sensitive scenarios) */ export declare const noOpTracer: Tracer; /** * Tracing provider configuration */ export interface TracingConfig { enabled: boolean; exporter?: SpanExporter; serviceName?: string; serviceVersion?: string; } /** * Tracing provider */ export declare class TracingProvider { private tracer; private config; constructor(config?: Partial); getTracer(): Tracer; isEnabled(): boolean; createSpan(name: string, attributes?: SpanAttributes): Span; withSpan(name: string, fn: (span: Span) => Promise): Promise; propagateContext(carrier: Record): void; extractContext(carrier: Record): SpanContext | null; } /** * Default tracing provider */ export declare const defaultTracingProvider: TracingProvider;