Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Span

Package version

An interface that represents a span. A span represents a single operation within a trace. Examples of span might include remote procedure calls or a in-process function calls to sub-components. A Trace has a single, top-level "root" Span that in turn may have zero or more child Spans, which in turn may have children.

Spans are created by the Tracer.startSpan method.

Hierarchy

  • Span

Implemented by

Index

Methods

addEvent

  • Adds an event to the Span.

    Parameters

    • name: string

      the name of the event.

    • Optional attributesOrStartTime: SpanAttributes | TimeInput

      the attributes that will be added; these are associated with this event. Can be also a start time if type is TimeInput and 3rd param is undefined

    • Optional startTime: TimeInput

      start time of the event.

    Returns this

context

  • Returns the SpanContext object associated with this Span.

    Get an immutable, serializable identifier for this span that can be used to create new child spans. Returned SpanContext is usable even after the span ends.

    Returns SpanContext

    the SpanContext object associated with this Span.

end

  • Marks the end of Span execution.

    Call to End of a Span MUST not have any effects on child spans. Those may still be running and can be ended later.

    Do not return this. The Span generally should not be used after it is ended so chaining is not desired in this context.

    Parameters

    • Optional endTime: TimeInput

      the time to set as Span's end time. If not provided, use the current time as the span's end time.

    Returns void

isRecording

  • isRecording(): boolean
  • Returns the flag whether this span will be recorded.

    Returns boolean

    true if this Span is active and recording information like events with the AddEvent operation and attributes using setAttributes.

recordException

  • Sets exception as a span event

    Parameters

    • exception: Exception

      the exception the only accepted values are string or Error

    • Optional time: TimeInput

      the time to set as Span's event time. If not provided, use the current time.

    Returns void

setAttribute

  • Sets an attribute to the span.

    Sets a single Attribute with the key and value passed as arguments.

    Parameters

    • key: string

      the key for this attribute.

    • value: SpanAttributeValue

      the value for this attribute. Setting a value null or undefined is invalid and will result in undefined behavior.

    Returns this

setAttributes

  • Sets attributes to the span.

    Parameters

    • attributes: SpanAttributes

      the attributes that will be added. null or undefined attribute values are invalid and will result in undefined behavior.

    Returns this

setStatus

  • Sets a status to the span. If used, this will override the default Span status. Default is SpanStatusCode.UNSET. SetStatus overrides the value of previous calls to SetStatus on the Span.

    Parameters

    Returns this

updateName

  • updateName(name: string): this
  • Updates the Span name.

    This will override the name provided via Tracer.startSpan.

    Upon this update, any sampling behavior based on Span name will depend on the implementation.

    Parameters

    • name: string

      the Span name.

    Returns this

Generated using TypeDoc