Skip to main content

Function: getActiveSpan()

getActiveSpan(): undefined | Span

Defined in: src/observability/tracer.ts:86

Gets the currently active span.

Returns

undefined | Span

Active span or undefined if no span is active

Remarks

Returns the span from the current execution context. Useful for adding attributes to an existing span.

Example

const span = getActiveSpan();
if (span) {
span.setAttribute('user.id', userId);
}

Since

0.1.0