withSpan MethodStatic

If OpenTelemetry tracing is enabled, creates a new span and runs the provided function in it. If OpenTelemetry tracing is not enabled, runs the provided function.

withSpan<T>(name: string, fn: () => Promise<T>, options?: SpanOptions, parentContext?: SpanContext): Promise<T>

Parameter Type Description
name string name of the new span
fn () => Promise<T> function to run inside the new span
options SpanOptions span options
parentContext SpanContext optional context used to retrieve parent span id

Returns - Promise<T>

Defined in

Last Updated: 06 September, 2024