add_event()
add_event()
Signature
add_event(name: str,attributes: Dict = None,timestamp: int = None,) -> bool
Returns True if the event was added successfully.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Event name. |
attributes | Dict | None | Key-value pairs attached to the event. |
timestamp | int | None | Unix timestamp in nanoseconds. Defaults to current time. |
Example
from respan import Respan, task, get_clientrespan = Respan(api_key="your-api-key")@task(name="process_batch")def process_batch(items):client = get_client()client.add_event("batch_started", {"item_count": len(items)})results = [item * 2 for item in items]client.add_event("batch_completed", {"result_count": len(results)})return resultsprocess_batch([1, 2, 3])