Libraries
    Preparing search index...

    Interface SpanHandle

    Handle returned by the disposable form of withSpan.

    Implements AsyncDisposable so it can be used with await using:

    await using handle = withSpan('my.operation');
    handle.span.setAttribute('key', value);
    try {
    // ... do work ...
    } catch (err) {
    handle.fail(err);
    throw err;
    }
    // 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.

    interface SpanHandle {
        span: Span;
        "[asyncDispose]"(): Promise<void>;
        fail(err: unknown): void;
    }
    Index

    Properties

    Methods

    Properties

    span: Span

    The underlying OTel span. Use it to set attributes or add events.

    Methods

    • Ends the span. Called automatically when exiting an await using block.

      Returns Promise<void>

    • Records an exception and marks the span as errored.

      Idempotent — safe to call in a catch block even if the same error might be reported elsewhere.

      Parameters

      • err: unknown

      Returns void