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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SpanBuilder(
name,kind,traceId,spanId,parentSpanId?,startTimeMs?):SpanBuilder
Defined in: src/observability/tracing.ts:98
Parameters
Section titled “Parameters”string
traceId
Section titled “traceId”string
spanId
Section titled “spanId”string
parentSpanId?
Section titled “parentSpanId?”string
startTimeMs?
Section titled “startTimeMs?”number = ...
Returns
Section titled “Returns”SpanBuilder
Properties
Section titled “Properties”
readonlykind:SpanKind
Defined in: src/observability/tracing.ts:100
readonlyname:string
Defined in: src/observability/tracing.ts:99
parentSpanId?
Section titled “parentSpanId?”
readonlyoptionalparentSpanId:string
Defined in: src/observability/tracing.ts:103
spanId
Section titled “spanId”
readonlyspanId:string
Defined in: src/observability/tracing.ts:102
startTimeMs
Section titled “startTimeMs”
readonlystartTimeMs:number
Defined in: src/observability/tracing.ts:104
traceId
Section titled “traceId”
readonlytraceId:string
Defined in: src/observability/tracing.ts:101
Methods
Section titled “Methods”addEvent()
Section titled “addEvent()”addEvent(
name,attributes?):this
Defined in: src/observability/tracing.ts:114
Record a timestamped event with optional attributes. Chainable.
Parameters
Section titled “Parameters”string
attributes?
Section titled “attributes?”Record<string, string | number | boolean>
Returns
Section titled “Returns”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.
Returns
Section titled “Returns”setAttribute()
Section titled “setAttribute()”setAttribute(
key,value):this
Defined in: src/observability/tracing.ts:108
Set a single attribute. Chainable.
Parameters
Section titled “Parameters”string
string | number | boolean
Returns
Section titled “Returns”this
setStatus()
Section titled “setStatus()”setStatus(
code,message?):this
Defined in: src/observability/tracing.ts:123
Set the span status. Chainable.
Parameters
Section titled “Parameters”message?
Section titled “message?”string
Returns
Section titled “Returns”this