Overview
Spans track:- Operation timing (start and end)
- Operation metadata (name, description)
- Attributes for filtering and analysis
- Parent-child relationships
- Status and outcome
Creating Spans
startSpan
Create an active span that automatically becomes the parent of nested spans.StartSpanOptions
required
function
required
Function to execute within the span context. Receives the span as argument.
startInactiveSpan
Create an inactive span that doesn’t automatically become the active parent.startSpanManual
Create a span with manual control over when it finishes.Span Interface
Frompackages/core/src/types-hoist/span.ts:
spanContext()
Get context data for the span.string
32-character hex string representing the trace.
string
16-character hex string representing the span.
number
Trace flags (1 = sampled, 0 = not sampled).
setAttribute()
Set a single attribute on the span.setAttributes()
Set multiple attributes at once.setStatus()
Set the span status.0- Unset1- OK2- Error
updateName()
Update the span name.Sentry.updateSpanName(span, name) to ensure the name persists through instrumentation.