dd-trace
    Preparing search index...

    Interface Tracer

    Tracer is the entry-point of the Datadog tracing implementation.

    interface Tracer {
        aiguard: AIGuard;
        appsec: Appsec;
        default: Tracer;
        dogstatsd: DogStatsD;
        llmobs: LLMObs;
        tracer: Tracer;
        TracerProvider: TracerProvider;
        extract(format: string, carrier: any): null | SpanContext;
        getAllBaggageItems(): Record<string, string>;
        getBaggageItem(key: string): undefined | string;
        getRumData(): string;
        init(options?: TracerOptions): this;
        inject(spanContext: Span | SpanContext, format: string, carrier: any): void;
        removeAllBaggageItems(): Record<string, string>;
        removeBaggageItem(key: string): Record<string, string>;
        scope(): Scope;
        setBaggageItem(key: string, value: string): Record<string, string>;
        setUrl(url: string): this;
        setUser(user: User): Tracer;
        startSpan(name: string, options?: SpanOptions): Span;
        trace<T>(name: string, fn: (span: Span) => T): T;
        trace<T>(
            name: string,
            fn: (span: Span, done: (error?: Error) => void) => T,
        ): T;
        trace<T>(
            name: string,
            options: TraceOptions & SpanOptions,
            fn: (span?: Span, done?: (error?: Error) => void) => T,
        ): T;
        use<P extends keyof Plugins>(
            plugin: P,
            config?: boolean | Plugins[P],
        ): this;
        wrap<T = (...args: any[]) => any>(name: string, fn: T): T;
        wrap<T = (...args: any[]) => any>(
            name: string,
            options: TraceOptions & SpanOptions,
            fn: T,
        ): T;
        wrap<T = (...args: any[]) => any>(
            name: string,
            options: (...args: any[]) => TraceOptions & SpanOptions,
            fn: T,
        ): T;
    }

    Hierarchy

    • Tracer
      • Tracer
    Index

    Properties

    aiguard: AIGuard

    AI Guard SDK

    appsec: Appsec
    default: Tracer

    For compatibility with NodeNext + esModuleInterop: false

    dogstatsd: DogStatsD
    llmobs: LLMObs

    LLM Observability SDK

    tracer: Tracer

    Add tracer as a named export

    TracerProvider: TracerProvider

    Methods

    • Returns a SpanContext instance extracted from carrier in the given format.

      Parameters

      • format: string

        The format of the carrier.

      • carrier: any

        The carrier object.

      Returns null | SpanContext

      The extracted SpanContext, or null if no such SpanContext could be found in carrier

    • Returns Record<string, string>

    • Parameters

      • key: string

      Returns undefined | string

    • Returns an HTML string containing tags that should be included in the of a document to enable correlating the current trace with the RUM view. Otherwise, it is not possible to associate the trace used to generate the initial HTML document with a given RUM view. The resulting HTML document should not be cached as the meta tags are time-sensitive and are associated with a specific user.

      Note that this feature is currently not supported by the backend and using it will have no effect.

      Returns string

    • Injects the given SpanContext instance for cross-process propagation within carrier

      Parameters

      • spanContext: Span | SpanContext

        The SpanContext to inject into the carrier object. As a convenience, a Span instance may be passed in instead (in which case its .context() is used for the inject()).

      • format: string

        The format of the carrier.

      • carrier: any

        The carrier object.

      Returns void

    • Returns Record<string, string>

    • Parameters

      • key: string

      Returns Record<string, string>

    • Experimental

      Provide same functionality as OpenTelemetry Baggage: https://opentelemetry.io/docs/concepts/signals/baggage/

      Since the equivalent of OTel Context is implicit in dd-trace-js, these APIs act on the currently active baggage

      Work with storage('baggage'), therefore do not follow the same continuity as other APIs

      Parameters

      • key: string
      • value: string

      Returns Record<string, string>

    • Sets the URL for the trace agent. This should only be called after init() is called, only in cases where the URL needs to be set after initialization.

      Parameters

      • url: string

      Returns this

    • Links an authenticated user to the current trace.

      Parameters

      • user: User

        Properties of the authenticated user. Accepts custom fields.

      Returns Tracer

      The Tracer instance for chaining.

    • Starts and returns a new Span representing a logical unit of work.

      Parameters

      • name: string

        The name of the operation.

      • Optionaloptions: SpanOptions

        Options for the newly created span.

      Returns Span

      A new Span object.

    • Instruments a function by automatically creating a span activated on its scope.

      The span will automatically be finished when one of these conditions is met:

      • The function returns a promise, in which case the span will finish when the promise is resolved or rejected.
      • The function takes a callback as its second parameter, in which case the span will finish when that callback is called.
      • The function doesn't accept a callback and doesn't return a promise, in which case the span will finish at the end of the function execution.

      Type Parameters

      • T

      Parameters

      • name: string
      • fn: (span: Span) => T

      Returns T

    • Type Parameters

      • T

      Parameters

      • name: string
      • fn: (span: Span, done: (error?: Error) => void) => T

      Returns T

    • Type Parameters

      • T

      Parameters

      • name: string
      • options: TraceOptions & SpanOptions
      • fn: (span?: Span, done?: (error?: Error) => void) => T

      Returns T

    • Enable and optionally configure a plugin.

      Type Parameters

      • P extends keyof Plugins

      Parameters

      • plugin: P

        The name of a built-in plugin.

      • Optionalconfig: boolean | Plugins[P]

        Configuration options. Can also be false to disable the plugin.

      Returns this

    • Wrap a function to automatically create a span activated on its scope when it's called.

      The span will automatically be finished when one of these conditions is met:

      • The function returns a promise, in which case the span will finish when the promise is resolved or rejected.
      • The function takes a callback as its last parameter, in which case the span will finish when that callback is called.
      • The function doesn't accept a callback and doesn't return a promise, in which case the span will finish at the end of the function execution.

      Type Parameters

      • T = (...args: any[]) => any

      Parameters

      • name: string
      • fn: T

      Returns T

    • Type Parameters

      • T = (...args: any[]) => any

      Parameters

      Returns T

    • Type Parameters

      • T = (...args: any[]) => any

      Parameters

      • name: string
      • options: (...args: any[]) => TraceOptions & SpanOptions
      • fn: T

      Returns T