Skip to main content
Span types define the structure of spans used in distributed tracing.

Span Interface

From packages/core/src/types-hoist/span.ts:

SpanContextData

Fields

string
required
32-character hex string (128 bits) representing the trace.
string
required
16-character hex string (64 bits) representing the span.
number
required
Trace flags bitmap. 1 = sampled, 0 = not sampled.
boolean
Whether the span was propagated from a remote parent.

SpanJSON

Serialized span format:

Fields

string
required
Unique span identifier (16 hex characters).
string
required
Trace identifier (32 hex characters).
string
Parent span identifier, if this is a child span.
string
Span operation type (e.g., 'http.client', 'db.query').
string
Human-readable description of the span.
number
required
Unix timestamp (seconds) when span started.
number
Unix timestamp (seconds) when span ended.
string
Span status: 'ok', 'cancelled', 'unknown', etc.
SpanAttributes
required
Span attributes (key-value pairs).

SpanAttributes

Example

SpanStatus

Status Codes

Unset
Status not set.
Ok
Operation completed successfully.
Error
Operation failed.

Example

SpanOrigin

Indicates how the span was created:

Examples

SentrySpanArguments

Arguments for creating spans:

StartSpanOptions

Options for starting a span:

Fields

string
required
Span description.
string
Span operation type.
SpanAttributes
Initial span attributes.
SpanTimeInput
Custom start time (Date, number, or HrTime).
Span
Explicit parent span.
boolean
Only create span if there’s a parent.

Complete Example

Semantic Conventions

HTTP Spans

Database Spans

Custom Attributes