Tracing Class

Deprecated  in 4.4 - OpenTelemetry Tracing helpers will become internal in a future release. Apps should use @opentelemetry/api directly.

Enables OpenTelemetry tracing in addition to traditional logging.

Methods

Name Description
constructor(): Tracing    
enableOpenTelemetry(tracer: Tracer, api: { context: Pick<ContextAPI, "active" | "with">, trace: Pick<TraceAPI, "setSpan" | "setSpanContext" | "getSpan"> }): void Static Enable logging to OpenTelemetry.  
recordException(e: Error): void Static Adds a span event describing a runtime exception, as advised in OpenTelemetry documentation  
setAttributes(attributes: SpanAttributes): void Static Set attributes on currently active openTelemetry span.  
withSpan<T>(name: string, fn: () => Promise<T>, options?: SpanOptions, parentContext?: SpanContext): Promise<T> Static If OpenTelemetry tracing is enabled, creates a new span and runs the provided function in it.  

Defined in

Last Updated: 14 November, 2024