TracerShim wraps a api.Tracer and implements the OpenTracing tracer API.

Hierarchy

  • Tracer
    • TracerShim

Constructors

Methods

  • Parameters

    • name: string
    • fields: SpanOptions

    Returns Span

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

    OpenTracing defines a common set of format values (see FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has an expected carrier type.

    Consider this pseudocode example:

    // Use the inbound HTTP request's headers as a text map carrier.
    var headersCarrier = inboundHTTPReq.headers;
    var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
    var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
    

    Parameters

    • format: string

      the format of the carrier.

    • carrier: any

      the type of the carrier object is determined by the format.

    Returns null | SpanContext

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

  • Injects the given SpanContext instance for cross-process propagation within carrier. The expected type of carrier depends on the value of `format.

    OpenTracing defines a common set of format values (see FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has an expected carrier type.

    Consider this pseudocode example:

    var clientSpan = ...;
    ...
    // Inject clientSpan into a text carrier.
    var headersCarrier = {};
    Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
    // Incorporate the textCarrier into the outbound HTTP request header
    // map.
    Object.assign(outboundHTTPReq.headers, headersCarrier);
    // ... send the httpReq
    

    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

      see the documentation for the chosen format for a description of the carrier object.

    Returns void

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

    For example:

    // Start a new (parentless) root Span:
    var parent = Tracer.startSpan('DoWork');
    
    // Start a new (child) Span:
    var child = Tracer.startSpan('load-from-db', {
        childOf: parent.context(),
    });
    
    // Start a new async (FollowsFrom) Span:
    var child = Tracer.startSpan('async-cache-write', {
        references: [
            opentracing.followsFrom(parent.context())
        ],
    });
    

    Parameters

    • name: string

      the name of the operation (REQUIRED).

    • options: SpanOptions = {}

      options for the newly created span.

    Returns Span

    • a new Span object.