Skip to main content
zerotal

Documentation


Documentation / @zerotal/telemetry / Span

Class: Span

Defined in: telemetry/src/Span.ts:39

A single unit of work in a distributed trace.

Spans are created by Tracer.withSpan() and withSpan(). They are automatically ended and exported when the wrapped callback resolves or throws. Manual end() is only needed for fire-and-forget patterns.

Extended by

Constructors

Constructor

new Span(name, parentId?, traceId?, kind?): Span

Defined in: telemetry/src/Span.ts:42

Parameters

name

string

parentId?

string

traceId?

string

kind?

SpanKind = "internal"

Returns

Span

Properties

data

readonly data: SpanData

Defined in: telemetry/src/Span.ts:40

Accessors

durationMs

Get Signature

get durationMs(): number

Defined in: telemetry/src/Span.ts:91

Returns

number


isEnded

Get Signature

get isEnded(): boolean

Defined in: telemetry/src/Span.ts:95

Returns

boolean

Methods

setAttribute()

setAttribute(key, value): this

Defined in: telemetry/src/Span.ts:57

Parameters

key

string

value

string | number | boolean

Returns

this


setAttributes()

setAttributes(attrs): this

Defined in: telemetry/src/Span.ts:62

Parameters

attrs

Record<string, string | number | boolean>

Returns

this


setStatus()

setStatus(code, message?): this

Defined in: telemetry/src/Span.ts:67

Parameters

code

"ok" | "error"

message?

string

Returns

this


addEvent()

addEvent(name, attributes?): this

Defined in: telemetry/src/Span.ts:72

Parameters

name

string

attributes?

Record<string, unknown>

Returns

this


recordException()

recordException(error): this

Defined in: telemetry/src/Span.ts:79

Parameters

error

Error

Returns

this


end()

end(): void

Defined in: telemetry/src/Span.ts:87

Returns

void