Skip to content

SpanBuilder

Defined in: src/observability/tracing.ts:90

Mutable span builder - accumulates attributes, events, and status during a request lifecycle. Call end to produce an immutable ReadableSpan.

new SpanBuilder(name, kind, traceId, spanId, parentSpanId?, startTimeMs?): SpanBuilder

Defined in: src/observability/tracing.ts:98

string

SpanKind

string

string

string

number = ...

SpanBuilder

readonly kind: SpanKind

Defined in: src/observability/tracing.ts:100


readonly name: string

Defined in: src/observability/tracing.ts:99


readonly optional parentSpanId: string

Defined in: src/observability/tracing.ts:103


readonly spanId: string

Defined in: src/observability/tracing.ts:102


readonly startTimeMs: number

Defined in: src/observability/tracing.ts:104


readonly traceId: string

Defined in: src/observability/tracing.ts:101

addEvent(name, attributes?): this

Defined in: src/observability/tracing.ts:114

Record a timestamped event with optional attributes. Chainable.

string

Record<string, string | number | boolean>

this


end(): ReadableSpan

Defined in: src/observability/tracing.ts:134

Finalize the span and return an immutable ReadableSpan.

Sets endTimeMs on first call; subsequent calls return the same snapshot with defensive copies of mutable fields.

ReadableSpan


setAttribute(key, value): this

Defined in: src/observability/tracing.ts:108

Set a single attribute. Chainable.

string

string | number | boolean

this


setStatus(code, message?): this

Defined in: src/observability/tracing.ts:123

Set the span status. Chainable.

SpanStatusCode

string

this