@launchdarkly/observability + @launchdarkly/session-replay
    Preparing search index...

    Interface Observe

    interface Observe {
        recordCount: (metric: OTelMetric) => void;
        recordError: (
            error: any,
            message?: string,
            payload?: { [key: string]: string },
            source?: string,
            type?: ErrorMessageType,
        ) => void;
        recordGauge: (metric: OTelMetric) => void;
        recordHistogram: (metric: OTelMetric) => void;
        recordIncr: (metric: Omit<OTelMetric, "value">) => void;
        recordLog: (
            message: any,
            level:
                | "error"
                | "assert"
                | "count"
                | "countReset"
                | "debug"
                | "dir"
                | "dirxml"
                | "group"
                | "groupCollapsed"
                | "groupEnd"
                | "info"
                | "log"
                | "table"
                | "time"
                | "timeEnd"
                | "timeLog"
                | "trace"
                | "warn",
            metadata?: Attributes,
        ) => void;
        recordUpDownCounter: (metric: OTelMetric) => void;
        start: () => Promise<void>;
        startManualSpan: {
            <F extends (span: Span) => ReturnType<F>>(
                name: string,
                fn: F,
            ): ReturnType<F>;
            <F extends (span: Span) => ReturnType<F>>(
                name: string,
                options: SpanOptions,
                fn: F,
            ): ReturnType<F>;
            <F extends (span: Span) => ReturnType<F>>(
                name: string,
                options: SpanOptions,
                context: Context,
                fn: F,
            ): ReturnType<F>;
        };
        startSpan: {
            <F extends (span?: Span) => ReturnType<F>>(
                name: string,
                fn: F,
            ): ReturnType<F>;
            <F extends (span?: Span) => ReturnType<F>>(
                name: string,
                options: SpanOptions,
                fn: F,
            ): ReturnType<F>;
            <F extends (span?: Span) => ReturnType<F>>(
                name: string,
                options: SpanOptions,
                context: Context,
                fn: F,
            ): ReturnType<F>;
        };
        stop: () => Promise<void>;
        getHooks(metadata: LDPluginEnvironmentMetadata): Hook[];
        getLDContextKeyAttributes(): undefined | Attributes;
        register(
            client: LDClient,
            environmentMetadata: LDPluginEnvironmentMetadata,
        ): void;
        removeAttributes(keys: string[]): void;
        setAttributes(
            attributes: Record<string, AttributeValue | null | undefined>,
        ): void;
        setLDContextKeyAttributes(contextKeys: Attributes): void;
    }

    Implemented by

    Index

    Properties

    recordCount: (metric: OTelMetric) => void

    Record arbitrary metric values via as a Counter. A Counter efficiently records an increment in a metric, such as number of cache hits. Values with the same metric name and attributes are aggregated via the OTel SDK. See https://opentelemetry.io/docs/specs/otel/metrics/data-model/ for more details.

    recordError: (
        error: any,
        message?: string,
        payload?: { [key: string]: string },
        source?: string,
        type?: ErrorMessageType,
    ) => void

    Calling this method will report an error in Highlight and map it to the current session being recorded. A common use case for H.error is calling it right outside of an error boundary.

    recordGauge: (metric: OTelMetric) => void

    Record arbitrary metric values via as a Gauge. A Gauge records any point-in-time measurement, such as the current CPU utilization %. Values with the same metric name and attributes are aggregated via the OTel SDK. See https://opentelemetry.io/docs/specs/otel/metrics/data-model/ for more details.

    recordHistogram: (metric: OTelMetric) => void

    Record arbitrary metric values via as a Histogram. A Histogram efficiently records near-by point-in-time measurement into a bucketed aggregate. Values with the same metric name and attributes are aggregated via the OTel SDK. See https://opentelemetry.io/docs/specs/otel/metrics/data-model/ for more details.

    recordIncr: (metric: Omit<OTelMetric, "value">) => void

    Record arbitrary metric values via as a Counter. A Counter efficiently records an increment in a metric, such as number of cache hits. Values with the same metric name and attributes are aggregated via the OTel SDK. See https://opentelemetry.io/docs/specs/otel/metrics/data-model/ for more details.

    recordLog: (
        message: any,
        level:
            | "error"
            | "assert"
            | "count"
            | "countReset"
            | "debug"
            | "dir"
            | "dirxml"
            | "group"
            | "groupCollapsed"
            | "groupEnd"
            | "info"
            | "log"
            | "table"
            | "time"
            | "timeEnd"
            | "timeLog"
            | "trace"
            | "warn",
        metadata?: Attributes,
    ) => void

    Record arbitrary logs from your own integrations or manual. Useful when you don't want to emit a console log to the browser dev tools but still want to report a custom log.

    recordUpDownCounter: (metric: OTelMetric) => void

    Record arbitrary metric values via as a UpDownCounter. A UpDownCounter efficiently records an increment or decrement in a metric, such as number of paying customers. Values with the same metric name and attributes are aggregated via the OTel SDK. See https://opentelemetry.io/docs/specs/otel/metrics/data-model/ for more details.

    start: () => Promise<void>

    Start the observability data capture when running in manualStart mode. Can safely be called before the SDK has initialized (e.g. before the plugin registers): the call resolves once the SDK is attached and started, without throwing.

    startManualSpan: {
        <F extends (span: Span) => ReturnType<F>>(
            name: string,
            fn: F,
        ): ReturnType<F>;
        <F extends (span: Span) => ReturnType<F>>(
            name: string,
            options: SpanOptions,
            fn: F,
        ): ReturnType<F>;
        <F extends (span: Span) => ReturnType<F>>(
            name: string,
            options: SpanOptions,
            context: Context,
            fn: F,
        ): ReturnType<F>;
    }

    Starts a new span for tracing in Highlight. The span will be ended when the end() is called on the span. It returns whatever is returned from the callback function.

    H.startManualSpan('span-name', options, (span) => {
    span.addEvent('event-name', { key: 'value' })
    span.setAttribute('key', 'value')
    await someAsyncFunction()
    span.end()
    })
    const span = H.startManualSpan('span-name', (s) => s)
    span.addEvent('event-name', { key: 'value' })
    await someAsyncFunction()
    span.end()

    The name of the span.

    Options for the span.

    The context for the span.

    The function to run in the span.

    startSpan: {
        <F extends (span?: Span) => ReturnType<F>>(
            name: string,
            fn: F,
        ): ReturnType<F>;
        <F extends (span?: Span) => ReturnType<F>>(
            name: string,
            options: SpanOptions,
            fn: F,
        ): ReturnType<F>;
        <F extends (span?: Span) => ReturnType<F>>(
            name: string,
            options: SpanOptions,
            context: Context,
            fn: F,
        ): ReturnType<F>;
    }

    Starts a new span for tracing in Highlight. The span will be ended when the callback function returns.

    H.startSpan('span-name', callbackFn)
    
    H.startSpan('span-name', options, callbackFn)
    
    H.startSpan('span-name', options, context, callbackFn)
    
    H.startSpan('span-name', async (span) => {
    span.setAttribute('key', 'value')
    await someAsyncFunction()
    })

    The name of the span.

    Options for the span.

    The context for the span.

    The function to run in the span.

    stop: () => Promise<void>

    Stop the observability data capture. Can safely be called before the SDK has initialized; before start() it cancels a pending start instead of throwing.

    Methods

    • Removes attributes previously added with setAttributes. Telemetry recorded afterwards no longer carries them.

      Parameters

      • keys: string[]

      Returns void

      LDObserve.removeAttributes(['utm_campaign'])
      
    • Adds attributes to all telemetry recorded from now on: every span (including automatically instrumented ones such as document load, fetch/XHR, clicks and page views), log, error and metric.

      Calling it again merges with the attributes already set; a null or undefined value removes that key. Attributes passed to an individual call (for example recordLog metadata or metric attributes) take precedence over these. Keys in namespaces the SDK sets itself (highlight.*, launchdarkly.*, session.*, context.contextKeys.*) are ignored.

      Attributes are held in memory for the current page load only: they are never persisted, and a full page load starts without them.

      Each attribute is also added to every metric, so a value with many distinct values (such as a user ID) creates as many metric series.

      Parameters

      • attributes: Record<string, AttributeValue | null | undefined>

      Returns void

      LDObserve.setAttributes({ utm_campaign: 'spring_promo', utm_source: 'email' })