@launchdarkly/observability-react-native
    Preparing search index...

    Interface SpanScope

    A handle to a span started with Observe.withSpan.

    A scope captures its own span context, so child spans created via SpanScope.child are parented correctly even across await boundaries — without manually threading context through your code.

    interface SpanScope {
        ctx: Context;
        span: Span;
        active<T>(fn: () => T): T;
        child<T>(
            name: string,
            fn: (scope: SpanScope) => T,
            options?: WithSpanOptions,
        ): T;
    }
    Index

    Properties

    Methods

    Properties

    ctx: Context

    This span's context. Pass it anywhere an explicit parent Context is required.

    span: Span

    The underlying OpenTelemetry span.

    Methods

    • Run fn with this span active. Use this to parent auto-instrumented fetch/XMLHttpRequest spans that are started after an await (the point at which React Native loses the active context). Calls started in the synchronous portion of a Observe.withSpan callback are already parented automatically.

      Type Parameters

      • T

      Parameters

      • fn: () => T

        The callback to run with this span active

      Returns T

    • Start a child span parented to this scope, run fn, and end the span automatically. The span's status is set to OK on success, or ERROR (with the thrown error recorded) if fn throws or rejects.

      Because the parent is captured from this scope rather than read from the active context, the child nests correctly even when created after an await.

      Type Parameters

      • T

      Parameters

      • name: string

        The child span name

      • fn: (scope: SpanScope) => T

        The callback to run within the child scope

      • Optionaloptions: WithSpanOptions

        Optional span options

      Returns T