Handle returned by the disposable form of withSpan.
Implements AsyncDisposable so it can be used with await using:
await usinghandle = withSpan('my.operation'); handle.span.setAttribute('key', value); try { // ... do work ... } catch (err) { handle.fail(err); throwerr; } // span.end() is called automatically when the block exits
Note: The span created by the disposable form is NOT activated as
the current context span (OTel's public API requires a callback scope
for context propagation). DB / outbound-HTTP child spans created
inside the await using block will be siblings of this span (both
children of the enclosing HTTP span) rather than nested under it.
Use the callback form of withSpan when proper nesting is required.
Handle returned by the disposable form of withSpan.
Implements
AsyncDisposableso it can be used withawait using:Note: The span created by the disposable form is NOT activated as the current context span (OTel's public API requires a callback scope for context propagation). DB / outbound-HTTP child spans created inside the
await usingblock will be siblings of this span (both children of the enclosing HTTP span) rather than nested under it. Use the callback form ofwithSpanwhen proper nesting is required.