TracingSpan interface

Represents an implementation agnostic tracing span.

Methods

end()

Ends the span.

isRecording()

Returns true if this TracingSpan is recording information.

Depending on the span implementation, this may return false if the span is not being sampled.

recordException(string | Error)

Records an exception on a TracingSpan without modifying its status.

When recording an unhandled exception that should fail the span, please use setStatus instead.

setAttribute(string, unknown)

Sets a given attribute on a span.

setStatus(SpanStatus)

Sets the status of the span. When an error is provided, it will be recorded on the span as well.

Method Details

end()

Ends the span.

function end()

isRecording()

Returns true if this TracingSpan is recording information.

Depending on the span implementation, this may return false if the span is not being sampled.

function isRecording(): boolean

Returns

boolean

recordException(string | Error)

Records an exception on a TracingSpan without modifying its status.

When recording an unhandled exception that should fail the span, please use setStatus instead.

function recordException(exception: string | Error)

Parameters

exception

string | Error

The exception to record on the span.

setAttribute(string, unknown)

Sets a given attribute on a span.

function setAttribute(name: string, value: unknown)

Parameters

name

string

The attribute's name.

value

unknown

The attribute's value to set. May be any non-nullish value.

setStatus(SpanStatus)

Sets the status of the span. When an error is provided, it will be recorded on the span as well.

function setStatus(status: SpanStatus)

Parameters

status
SpanStatus

The SpanStatus to set on the span.