Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Tracer

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

Hierarchy

  • Tracer
    • Tracer

Index

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`

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

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: function): T
  • trace<T>(name: string, options: TraceOptions & SpanOptions, fn: function): 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.

    Type parameters

    • T

    Parameters

    • name: string
    • fn: function
        • (span?: Span, fn?: function): T
        • Parameters

          • Optional span: Span
          • Optional fn: function
              • (error?: Error): any
              • Parameters

                • Optional error: Error

                Returns any

          Returns T

    Returns T

  • Type parameters

    • T

    Parameters

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

          • Optional span: Span
          • Optional done: function
              • (error?: Error): string
              • Parameters

                • Optional error: Error

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

Generated using TypeDoc