DiagnosticsCollector that exports events to OpenTelemetry.
This class bridges the existing diagnostics system with OpenTelemetry's distributed tracing standard, enabling integration with platforms like Datadog, Honeycomb, Jaeger, and others.
OpenTelemetryExporter(options?: OpenTelemetryExporterOptions)
Creates a new OpenTelemetry exporter
activeSpans: Map<string, Span>
enableConsoleLogging: boolean
operationNames: Map<string, string>
serviceName: string
spanContexts: Map<string, unknown>
tracer: Tracer
clear(): void
Clears all active spans and state
emit(event: AnyDiagnosticEvent): void
Emits a custom diagnostic event as a span event
flattenMetadata(metadata: Record<string, unknown>): Record<string, string
| number
| boolean>
Flattens metadata object to simple key-value pairs
generateEventId(): string
Generates a unique event ID
Gets all collected events (not applicable for OpenTelemetry)
hashKey(key: string): string
Hashes a cache key for privacy
operationComplete(eventId: string,output?: Record<string, unknown>,): void
Records successful completion of an operation
operationError(eventId: string,error: Error,): void
Records an error during an operation
operationStart(operation: string,input?: Record<string, unknown>,): string
Records the start of an operation as an OpenTelemetry span
recordCacheEvent(operation: "hit"
| "miss"
| "write"
| "evict",key: string,size?: number,): void
Records a cache event as span attributes
recordMetric(metric: string,value: number,unit: string,dimensions?: Record<string, string>,): void
Records a performance metric as span attributes
recordNetworkEvent(method: string,url: string,statusCode?: number,durationMs?: number,responseSize?: number,): void
Records a network event as span attributes
sanitizeUrl(url: string): string
Sanitizes URL by removing query params and auth
setSpanAttribute(span: Span,key: string,value: unknown,): void
Safely sets a span attribute handling various types