dd-trace
    Preparing search index...

    Interface Profiling

    interface Profiling {
        runWithLabels<T>(
            labels: Record<string, string | number>,
            fn: () => T,
        ): T;
        setCustomLabelKeys(keys: Iterable<string>): void;
    }
    Index

    Methods

    • Runs a function with custom profiling labels attached to all wall profiler samples taken during its execution. Labels are key-value pairs that appear in the pprof output and can be used to filter flame graphs in the Datadog UI.

      Requires AsyncContextFrame (ACF) to be enabled. Supports nesting: inner calls merge labels with outer calls, with inner values taking precedence.

      When profiling is not enabled or ACF is not active, the function is still called but labels are silently dropped.

      Type Parameters

      • T

      Parameters

      • labels: Record<string, string | number>

        Custom labels to attach to profiler samples.

      • fn: () => T

        Function to execute with the labels.

      Returns T

      The return value of fn.

    • Declares the set of custom label keys that will be used with runWithLabels. This is used for profile upload metadata (so the Datadog UI knows which keys to index for filtering) and for pprof serialization optimization.

      Parameters

      • keys: Iterable<string>

        Custom label key names.

      Returns void