Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Tracer

Package version

Tracer provides an interface for creating Spans and propagating context in-process.

Users may choose to use manual or automatic Context propagation. Because of that this class offers APIs to facilitate both usages.

Hierarchy

  • Tracer

Implemented by

Index

Methods

bind

  • bind<T>(target: T, span?: Span): T
  • Bind a span as the target's scope or propagate the current one.

    Type parameters

    • T

    Parameters

    • target: T

      Any object to which a scope need to be set

    • Optional span: Span

    Returns T

getBinaryFormat

getCurrentSpan

  • getCurrentSpan(): Span | null
  • Returns the current Span from the current context if available.

    If there is no Span associated with the current context, null is returned.

    Returns Span | null

    Span The currently active Span

getHttpTextFormat

  • Returns the HttpTextFormat interface which can inject/extract Spans.

    If no tracer implementation is provided, this defaults to the W3C Trace Context HTTP text format ({@link HttpTraceContext}). For more details see W3C Trace Context.

    Returns HttpTextFormat

recordSpanData

  • recordSpanData(span: Span): void
  • Send a pre-populated span object to the exporter. Sampling and recording decisions as well as other collection optimizations are the responsibility of a caller.

    todo:

    Pending API discussion. Revisit if Span or SpanData should be passed in here once this is sorted out.

    Parameters

    • span: Span

      Span Data to be reported to all exporters.

    Returns void

startSpan

  • Starts a new Span.

    Parameters

    • name: string

      The name of the span

    • Optional options: SpanOptions

    Returns Span

    Span The newly created span

withSpan

  • withSpan<T>(span: Span, fn: T): ReturnType<T>
  • Executes the function given by fn within the context provided by Span

    example

    tracer.withSpan(span, function() { ... });

    Type parameters

    • T: function

    Parameters

    • span: Span

      The span that provides the context

    • fn: T

      The function to be executed inside the provided context

    Returns ReturnType<T>

Generated using TypeDoc