Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TestSpan

Package version

A mock span useful for testing.

Hierarchy

Implements

  • any

Index

Constructors

constructor

  • new TestSpan(parentTracer: Tracer, name: string, context: SpanContext, kind: SpanKind, parentSpanId?: undefined | string, startTime?: TimeInput): TestSpan
  • Starts a new Span.

    Parameters

    • parentTracer: Tracer

      The tracer that created this Span

    • name: string

      The name of the span.

    • context: SpanContext

      The SpanContext this span belongs to

    • kind: SpanKind

      The SpanKind of this Span

    • Optional parentSpanId: undefined | string

      The identifier of the parent Span

    • Default value startTime: TimeInput = Date.now()

      The startTime of the event (defaults to now)

    Returns TestSpan

Properties

attributes

attributes: Attributes

Known attributes, if any.

endCalled

endCalled: boolean

True if end() has been called on the Span

kind

kind: SpanKind

The Span's kind

name

name: string

The Span's current name

Optional parentSpanId

parentSpanId: undefined | string

The id of the parent Span, if any.

startTime

startTime: TimeInput

The start time of the Span

status

status: Status

The Span's current status

Methods

addEvent

  • addEvent(_name: string, _attributes?: Attributes): this
  • Adds an event to the Span

    Parameters

    • _name: string

      The name of the event

    • Optional _attributes: Attributes

      The associated attributes to add for this event

    Returns this

context

end

  • end(_endTime?: undefined | number): void
  • Marks the end of Span execution.

    Parameters

    • Optional _endTime: undefined | number

      The time to use as the Span's end time. Defaults to the current time.

    Returns void

isRecording

  • isRecording(): boolean

setAttribute

  • setAttribute(key: string, value: unknown): this

setAttributes

  • setAttributes(attributes: Attributes): this

setStatus

  • setStatus(status: Status): this

tracer

  • tracer(): Tracer

updateName

  • updateName(_name: string): this

Generated using TypeDoc