addSpanEvent()
Add a timestamped event to the current span
Overview
addSpanEvent() adds a named event with optional attributes to the currently active span. Events are useful for marking significant milestones or state changes within a span.
Signature
Basic Usage
Batch Processing Events
API Call Events
State Transitions
Error Context Events
Performance Milestones
Parameters
name
Event name for identification
attributes
Optional key-value pairs with additional event context
Best Practices
- Use events to mark significant milestones in span execution
- Include relevant attributes for context (counts, durations, status codes)
- Add events before and after critical operations
- Use consistent naming conventions for events
- Events are automatically timestamped
- Only call within an active span
- Events are visible in the Respan dashboard timeline