Options
All
  • Public
  • Public/Protected
  • All
Menu

This class represents a basic tracer.

Hierarchy

  • Tracer

Implements

Index

Constructors

Properties

instrumentationLibrary: InstrumentationLibrary
resource: IResource

Methods

  • startActiveSpan<F>(name: string, fn: F): ReturnType<F>
  • startActiveSpan<F>(name: string, opts: SpanOptions, fn: F): ReturnType<F>
  • startActiveSpan<F>(name: string, opts: SpanOptions, ctx: Context, fn: F): ReturnType<F>
  • 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.

    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();

    Type Parameters

    • F extends ((span: Span) => ReturnType<F>)

    Parameters

    • name: string

      The name of the span

    • fn: F

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

    Returns ReturnType<F>

    return value of fn

  • Type Parameters

    • F extends ((span: Span) => ReturnType<F>)

    Parameters

    Returns ReturnType<F>

  • Type Parameters

    • F extends ((span: Span) => ReturnType<F>)

    Parameters

    Returns ReturnType<F>

Generated using TypeDoc