withSpan
withSpan<
T>(tracer,name,attrs,fn):Promise<T>
Defined in: packages/core/src/telemetry/traces.ts:75
Wrap an async operation in an OTel span with attributes and automatic error recording.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”tracer
Section titled “tracer”Tracer
a valid Tracer instance (real OTel or no-op)
string
the span name
Record<string, string | number | boolean>
key-value attributes to set on the span
() => Promise<T>
async function to execute within the span
Returns
Section titled “Returns”Promise<T>
the result of fn
Precondition
Section titled “Precondition”tracer is a valid Tracer instance
Postcondition
Section titled “Postcondition”span is ended after fn completes or throws
Idempotency
Section titled “Idempotency”Safe — creates a new span per call