Interface Tracer

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

interface Tracer {
    TracerProvider: TracerProvider;
    appsec: Appsec;
    default: export=.Tracer;
    dogstatsd: DogStatsD;
    llmobs: LLMObs;
    tracer: export=.Tracer;
    extract(format, carrier): null | export=.SpanContext;
    getRumData(): string;
    init(options?): this;
    inject(spanContext, format, carrier): void;
    scope(): Scope;
    setUrl(url): this;
    setUser(user): export=.Tracer;
    startSpan(name, options?): export=.Span;
    trace<T>(name, fn): T;
    trace<T>(name, fn): T;
    trace<T>(name, options, fn): T;
    use<P>(plugin, config?): this;
    wrap<T>(name, fn): T;
    wrap<T>(name, options, fn): T;
    wrap<T>(name, options, fn): T;
}

Hierarchy

  • Tracer
    • Tracer

Properties

TracerProvider: TracerProvider
appsec: Appsec
default: export=.Tracer

For compatibility with NodeNext + esModuleInterop: false

dogstatsd: DogStatsD
llmobs: LLMObs

LLM Observability SDK

tracer: export=.Tracer

Add tracer as a named export

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 | export=.SpanContext

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

  • 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

  • Initializes the tracer. This should be called before importing other libraries.

    Parameters

    Returns this

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

    Parameters

    • spanContext: export=.Span | export=.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

  • 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 export=.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.

    • Optional options: SpanOptions

      Options for the newly created span.

    Returns export=.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) => T)

    Returns T

  • Type Parameters

    • T

    Parameters

    • name: string
    • fn: ((span, done) => T)
        • (span, done): T
        • Parameters

          • span: export=.Span
          • done: ((error?) => void)
              • (error?): void
              • Parameters

                • Optional error: Error

                Returns void

          Returns T

    Returns T

  • Type Parameters

    • T

    Parameters

    • name: string
    • options: TraceOptions & SpanOptions
    • fn: ((span?, done?) => T)
        • (span?, done?): T
        • Parameters

          • Optional span: export=.Span
          • Optional done: ((error?) => void)
              • (error?): void
              • Parameters

                • Optional error: Error

                Returns void

          Returns 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.

    • Optional config: 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)

    Parameters

    • name: string
    • fn: T

    Returns T

  • Type Parameters

    • T = ((...args) => any)

    Parameters

    Returns T

  • Type Parameters

    • T = ((...args) => any)

    Parameters

    Returns T