Skip to main content
Web Client SDK:
Node.js SDK:
You don’t instantiate Span directly. Create one with trace.startSpan() or the trace.span() wrapper, and nest with span.startSpan(). See Spans for a conceptual overview.

Properties

id

The span’s W3C Trace Context id (16 lowercase hex characters). Available immediately.
Also available as getSpanId(): string.

Methods

setAttribute()

Set a single span attribute. Set attributes at creation or synchronously afterwards — before the span first flushes.

Parameters

Examples


setAttributes()

Set multiple span attributes at once.

Examples


addEvent()

Record an event nested under this span.

Parameters

Examples


info() / warn() / error()

Convenience methods for recording an event under this span with a severity.

Examples


startSpan()

Open a child span parented to this span.

Parameters

Examples


end()

End the span, optionally setting an OTLP status and message. Idempotent — a second call is ignored.

SpanEndOptions

Examples


isEnded()

Whether end() has been called.

Method Chaining

setAttribute, setAttributes, addEvent, info, warn, and error return the span for chaining:

Next Steps

Spans (Concept)

How spans nest and time work

Trace

startSpan() and span() on the trace