Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TestSpan

Package version

A mock span useful for testing.

Hierarchy

Implements

  • Span

Index

Constructors

constructor

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

    Parameters

    • parentTracer: TestTracer

      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

    • Optional startTime: TimeInput

      The startTime of the event (defaults to now)

    Returns TestSpan

Properties

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

addLink

  • addLink(_spanContext: SpanContext, _attributes?: Attributes): this
  • Adds a link to the Span.

    Parameters

    • _spanContext: SpanContext

      the context of the linked span

    • Optional _attributes: Attributes

      attributes to be added that are associated with the link

    Returns this

context

  • context(): SpanContext
  • Returns the SpanContext associated with this Span.

    Returns SpanContext

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

isRecordingEvents

  • isRecordingEvents(): boolean
  • Returns whether this span will be recorded

    Returns boolean

setAttribute

  • setAttribute(_key: string, _value: unknown): this
  • Sets an attribute on the Span

    Parameters

    • _key: string

      the attribute key

    • _value: unknown

      the attribute value

    Returns this

setAttributes

  • setAttributes(_attributes: Attributes): this
  • Sets attributes on the Span

    Parameters

    • _attributes: Attributes

      the attributes to add

    Returns this

setStatus

  • setStatus(status: Status): this
  • Sets a status on the span. Overrides the default of CanonicalCode.OK.

    Parameters

    • status: Status

      The status to set.

    Returns this

tracer

  • tracer(): Tracer
  • Returns the Tracer that created this Span

    Returns Tracer

updateName

  • updateName(_name: string): this
  • Updates the name of the Span

    Parameters

    • _name: string

      the new Span name

    Returns this

Generated using TypeDoc