Function: addSpanEvent()
@arolariu/website / instrumentation.server / addSpanEvent
Function: addSpanEvent()
addSpanEvent(
name,attributes?):void
Defined in: instrumentation.server.ts:1033
Add an event to the currently active span.
Events represent discrete occurrences at a specific point in time during a span. They're useful for recording timestamps of significant operations or milestones.
Parameters
name
string
Event name (e.g., "cache.hit", "validation.complete")
attributes?
Optional attributes providing event context
Returns
void
Remarks
- Events are timestamped automatically
- Use events for high-cardinality data (unlike span attributes)
- If no span is active, this is a no-op (safe to call)
- Events appear in trace visualization tools
Example
addSpanEvent('cache.hit', { cache_key: 'user:123' });
addSpanEvent('validation.start');
addSpanEvent('retry.attempt', { attempt: 2, delay_ms: 1000 });
See
https://opentelemetry.io/docs/specs/otel/trace/api/#add-events
// was this page useful?