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

    Interface Observe

    interface Observe {
        flush(): Promise<void>;
        getContextFromSpan(span: Span): Context;
        getSessionInfo(): SessionInfo;
        getTracer(): LDTracer;
        isInitialized(): boolean;
        parseHeaders(headers: Record<string, string>): RequestContext;
        recordCount(metric: Metric): void;
        recordError(
            error: Error,
            attributes?: Attributes,
            options?: { span: Span },
        ): void;
        recordHistogram(metric: Metric): void;
        recordIncr(metric: Metric): void;
        recordLog(message: any, level: string, attributes?: Attributes): void;
        recordMetric(metric: Metric): void;
        recordUpDownCounter(metric: Metric): void;
        runWithHeaders(
            name: string,
            headers: Record<string, string>,
            cb: (span: Span) => any,
            options?: SpanOptions,
        ): any;
        startActiveSpan<T>(
            spanName: string,
            fn: (span: Span) => T,
            options?: SpanOptions,
            ctx?: Context,
        ): T;
        startSpan(spanName: string, options?: SpanOptions, ctx?: Context): Span;
        startWithHeaders(
            spanName: string,
            headers: Record<string, string>,
            options?: SpanOptions,
        ): Span;
        stop(): Promise<void>;
        track(
            key: string,
            properties?: TrackProperties,
            metricValue?: number,
        ): void;
        withSpan<T>(
            spanName: string,
            fn: (scope: SpanScope) => T,
            options?: WithSpanOptions,
        ): T;
    }
    Index

    Methods

    • Flush all pending telemetry data.

      Returns Promise<void>

    • Get the context from a span.

      Parameters

      • span: Span

        The span to get the context from

      Returns Context

    • Get the current session information.

      Returns SessionInfo

    • Get the OpenTelemetry LDTracer backing this SDK.

      Returns a standard OpenTelemetry Tracer (startSpan, startActiveSpan) plus LDTracer.withSpan for async-safe nested spans in React Native. Use this to follow the official OpenTelemetry JS documentation or integrate a third-party library that expects a Tracer. The tracer is wired to the same exporter/sampler as the rest of the SDK.

      Before the SDK finishes initializing (or when disableTraces is set) this returns a no-op tracer, so it is always safe to call. disableTraces affects only public custom tracing APIs; SDK auto-instrumentation is unaffected.

      Returns LDTracer

    • Check if the observability client is initialized.

      Returns boolean

    • Record a count metric.

      Parameters

      • metric: Metric

        The count metric to record

      Returns void

    • Record an error with optional context.

      Parameters

      • error: Error

        The error to record

      • Optionalattributes: Attributes

        Optional additionalattributes

      • Optionaloptions: { span: Span }

        Optional span options

      Returns void

    • Record a histogram metric.

      Parameters

      • metric: Metric

        The histogram metric to record

      Returns void

    • Record an increment metric.

      Parameters

      • metric: Metric

        The increment metric to record

      Returns void

    • Record a log message.

      Parameters

      • message: any

        The log message

      • level: string

        The log level

      • Optionalattributes: Attributes

        Optional additional attributes

      Returns void

    • Record an up/down counter metric.

      Parameters

      • metric: Metric

        The up/down counter metric to record

      Returns void

    • Run a function with header context.

      Parameters

      • name: string

        The span name

      • headers: Record<string, string>

        The headers

      • cb: (span: Span) => any

        The callback function

      • Optionaloptions: SpanOptions

        Optional span options

      Returns any

    • Start a new active span and run a callback function within its context.

      Type Parameters

      • T

      Parameters

      • spanName: string

        The span name

      • fn: (span: Span) => T

        The callback function to run with the active span

      • Optionaloptions: SpanOptions

        Optional span options

      • Optionalctx: Context

      Returns T

    • Start a new span without making it active.

      Parameters

      • spanName: string

        The span name

      • Optionaloptions: SpanOptions

        Optional span options

      • Optionalctx: Context

      Returns Span

    • Start a span with header context.

      Parameters

      • spanName: string

        The span name

      • headers: Record<string, string>

        The headers

      • Optionaloptions: SpanOptions

        Optional span options

      Returns Span

    • Stop the observability client.

      Returns Promise<void>

    • Record a custom track event as a track span.

      Mirrors the iOS and Android LDObserve.track(...) API (and LDClient.track): emits a span named track carrying the event key, an optional numeric value for LaunchDarkly numeric custom metrics, and any properties as additional span attributes.

      properties is a plain dictionary (like the native [String: Any] / Map<String, Any?> surfaces): nested objects are flattened with dot-separated keys (e.g. user.id), arrays of objects with indexed dotted keys (e.g. products.0.price), and homogeneous scalar arrays become array attributes. null / undefined values are skipped.

      Parameters

      • key: string

        The key for the event.

      • Optionalproperties: TrackProperties

        Optional data associated with the event; flattened and attached as span attributes.

      • OptionalmetricValue: number

        Optional numeric value used by LaunchDarkly experimentation for numeric custom metrics.

      Returns void

    • Start a span, run fn within it, and end the span automatically.

      This is an ergonomic wrapper over startSpan designed for React Native, where the active context is tracked only synchronously and is lost across each await. The SpanScope passed to fn exposes a SpanScope.child method that parents child spans off the captured context, so the hierarchy is preserved across awaits and even under concurrent (Promise.all) work — without manually threading context.

      The span's status is set to OK on success, or ERROR (with the error recorded) if fn throws or returns a rejecting promise. If fn returns a promise, the span ends when it settles and the promise is returned.

      Type Parameters

      • T

      Parameters

      • spanName: string

        The span name

      • fn: (scope: SpanScope) => T

        The callback to run within the span's scope

      • Optionaloptions: WithSpanOptions

        Optional span options, including an explicit parent

      Returns T