Skip to main content

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

string
required
Event name for identification
Record<string, any>
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 Keywords AI dashboard timeline