Class ProxyTracer

Proxy tracer provided by the proxy tracer provider

Hierarchy

  • ProxyTracer

Implements

Constructors

  • Parameters

    Returns ProxyTracer

Properties

_delegate?: any
_getTracer: any

Try to get a tracer from the proxy tracer provider. If the proxy tracer provider has no delegate, return a noop tracer.

_provider: any
name: string
options?: TracerOptions
version?: string

Methods

  • Starts a new Span and calls the given function passing it the created span as first argument. Additionally the new span gets set in context and this context is activated for the duration of the function call.

    Type Parameters

    • F extends ((span) => unknown)

    Parameters

    • _name: string

      The name of the span

    • _options: SpanOptions | F

      function called in the context of the span and receives the newly created span as an argument

    • Optional _context: Context | F
      Optional
    • Optional _fn: F
      Optional

    Returns ReturnType<F>

    return value of fn

    Example

    const something = tracer.startActiveSpan('op', span => {
    try {
    do some work
    span.setStatus({code: SpanStatusCode.OK});
    return something;
    } catch (err) {
    span.setStatus({
    code: SpanStatusCode.ERROR,
    message: err.message,
    });
    throw err;
    } finally {
    span.end();
    }
    });

    Example

    const span = tracer.startActiveSpan('op', span => {
    try {
    do some work
    return span;
    } catch (err) {
    span.setStatus({
    code: SpanStatusCode.ERROR,
    message: err.message,
    });
    throw err;
    }
    });
    do some more work
    span.end();
  • Starts a new Span. Start the span without setting it on context.

    This method do NOT modify the current Context.

    Parameters

    • name: string

      The name of the span

    • Optional options: SpanOptions

      SpanOptions used for span creation

      Optional
    • Optional context: Context

      Context to use to extract parent

      Optional

    Returns Span

    Span The newly created span

    Example

    const span = tracer.startSpan('op');
    span.setAttribute('key', 'value');
    span.end();

Generated using TypeDoc