Skip to content

withSpan

withSpan<T>(name, fn, attributes?, parent?): Promise<T>

Defined in: tracing.ts:31

Run fn inside an internal span.

On throw the span records the exception, is marked ERROR, and the error is rethrown — mirroring the pino { err } convention.

T

string

Span name (domain.operation, never a high-cardinality value).

(span) => Promise<T>

Work to run with the span active.

Attributes

Fixed span attributes (no high-cardinality values in names).

Context

Parent context (defaults to the active context).

Promise<T>

Whatever fn returns.