/** * Distributed Tracing Service * * Provides OpenTelemetry-compatible distributed tracing for the application. * * Features: * - W3C Trace Context propagation * - Span lifecycle management * - Context-aware span creation * - Async context propagation * - Console and OTLP export options */ import { type SpanAttributes, type SpanData, type SpanOptions, type TraceContext, type TracerConfig } from '../types/tracing.types.js'; /** * Generate a random trace ID (32 hex characters) */ export declare function generateTraceId(): string; /** * Generate a random span ID (16 hex characters) */ export declare function generateSpanId(): string; /** * Span class for managing individual spans */ export declare class Span { private readonly config; private readonly data; private ended; constructor(name: string, context: TraceContext, options: SpanOptions | undefined, config: TracerConfig); /** * Get the span's trace context */ getContext(): TraceContext; /** * Get the span ID */ getSpanId(): string; /** * Get the trace ID */ getTraceId(): string; /** * Set a single attribute */ setAttribute(key: string, value: boolean | boolean[] | number | number[] | string | string[]): this; /** * Set multiple attributes */ setAttributes(attributes: SpanAttributes): this; /** * Add an event to the span */ addEvent(name: string, attributes?: SpanAttributes): this; /** * Set the span status to OK */ setOk(): this; /** * Set the span status to ERROR */ setError(message?: string): this; /** * Record an exception */ recordException(error: Error): this; /** * End the span */ end(endTime?: number): void; /** * Check if span is recording */ isRecording(): boolean; /** * Get span data (for export) */ getData(): SpanData; /** * Get duration in milliseconds */ getDuration(): number | undefined; } /** * Tracer class for creating and managing spans */ export declare class Tracer { private readonly config; constructor(config?: Partial); /** * Check if tracing is enabled */ isEnabled(): boolean; /** * Create a new span */ startSpan(name: string, options?: SpanOptions): Span; /** * Get the current active span */ getCurrentSpan(): Span | undefined; /** * Get current trace context */ getCurrentContext(): TraceContext | undefined; /** * Execute a function within a span */ withSpan(name: string, options: SpanOptions, fn: (span: Span) => Promise): Promise; /** * Execute a synchronous function within a span */ withSpanSync(name: string, options: SpanOptions, fn: (span: Span) => T): T; /** * Create a trace context */ private createContext; /** * Determine if a trace should be sampled */ private shouldSample; /** * Shutdown the tracer and flush pending spans */ shutdown(): Promise; /** * Get tracer configuration */ getConfig(): TracerConfig; } /** * Parse W3C Trace Context header (traceparent) */ export declare function parseTraceParent(header: string): null | TraceContext; /** * Format trace context as W3C Trace Context header (traceparent) */ export declare function formatTraceParent(context: TraceContext): string; /** * Get the global tracer instance */ export declare function getTracer(config?: Partial): Tracer; /** * Reset the global tracer and all tracing state (for testing) */ export declare function resetTracer(): Promise; /** * Convenience function to start a span using the global tracer */ export declare function startSpan(name: string, options?: SpanOptions): Span; /** * Convenience function to get the current span */ export declare function getCurrentSpan(): Span | undefined; /** * Convenience function to get current trace context */ export declare function getCurrentTraceContext(): TraceContext | undefined; /** * Decorator for tracing async methods */ export declare function traced(spanName?: string, options?: Omit): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Decorator for tracing sync methods */ export declare function tracedSync(spanName?: string, options?: Omit): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; //# sourceMappingURL=tracing.d.ts.map