Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Tracer

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

Hierarchy

  • Tracer
    • Tracer

Index

Properties

appsec

appsec: Appsec

Methods

extract

  • extract(format: string, carrier: any): SpanContext | null
  • 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 SpanContext | null

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

getRumData

  • getRumData(): string
  • Create and return a string that can be included in the of a document to enable RUM tracing to include it. The resulting string should not be cached.

    Returns string

init

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

    Parameters

    Returns this

inject

  • inject(spanContext: SpanContext | Span, format: string, carrier: any): void
  • Injects the given SpanContext instance for cross-process propagation within carrier

    Parameters

    • spanContext: SpanContext | Span

      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

scope

setUrl

  • setUrl(url: string): this
  • 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

setUser

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

startSpan

  • startSpan(name: string, options?: SpanOptions): Span
  • Starts and returns a new Span representing a logical unit of work.

    Parameters

    • name: string

      The name of the operation.

    • Optional options: SpanOptions

    Returns Span

    A new Span object.

trace

  • trace<T>(name: string, fn: (span?: Span, fn?: undefined | ((error?: Error) => any)) => T): T
  • trace<T>(name: string, options: TraceOptions & SpanOptions, fn: (span?: Span, done?: undefined | ((error?: Error) => string)) => T): T
  • 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.

    If the orphanable option is set to false, the function will not be traced unless there is already an active span or childOf option. Note that this option is deprecated and has been removed in version 4.0.

    Type parameters

    • T

    Parameters

    • name: string
    • fn: (span?: Span, fn?: undefined | ((error?: Error) => any)) => T
        • (span?: Span, fn?: undefined | ((error?: Error) => any)): T
        • Parameters

          • Optional span: Span
          • Optional fn: undefined | ((error?: Error) => any)

          Returns T

    Returns T

  • Type parameters

    • T

    Parameters

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

          • Optional span: Span
          • Optional done: undefined | ((error?: Error) => string)

          Returns T

    Returns T

use

  • use<P>(plugin: P, config?: Plugins[P] | boolean): this
  • Enable and optionally configure a plugin.

    Type parameters

    • P: keyof Plugins

    Parameters

    • plugin: P

      The name of a built-in plugin.

    • Optional config: Plugins[P] | boolean

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

    Returns this

wrap

  • wrap<T>(name: string, fn: T): T
  • wrap<T>(name: string, options: TraceOptions & SpanOptions, fn: T): T
  • wrap<T>(name: string, options: (...args: any[]) => TraceOptions & SpanOptions, fn: T): T
  • 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

    Parameters

    • name: string
    • fn: T

    Returns T

  • Type parameters

    • T

    Parameters

    Returns T

  • Type parameters

    • T

    Parameters

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

    Returns T

Generated using TypeDoc