From 1e771a6fde466f6545d0d5f94576c7fb5f405c76 Mon Sep 17 00:00:00 2001 From: Teo Date: Tue, 26 Nov 2024 23:40:43 -0600 Subject: [PATCH] feat(session/exporter): add event ID generation logic --- agentops/session/exporter.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/agentops/session/exporter.py b/agentops/session/exporter.py index b85d6e3e..93e9d8c9 100644 --- a/agentops/session/exporter.py +++ b/agentops/session/exporter.py @@ -120,9 +120,14 @@ def from_span_attributes(attrs: Union[Dict[str, AttributeValue], Mapping[str, At init_timestamp = attrs.get("event.timestamp") or event_data.get("init_timestamp", current_time) end_timestamp = attrs.get("event.end_timestamp") or event_data.get("end_timestamp", current_time) + # Get event ID - ensure it's a valid UUID string + event_id = event_data.get("id") + if not event_id: + event_id = str(uuid4()) + # Build base event structure base_kwargs = { - "id": attrs.get("event.id", str(uuid4())), + "id": event_id, # Use string ID directly "event_type": attrs.get("event.type", event_data.get("event_type", "unknown")), "init_timestamp": init_timestamp, "end_timestamp": end_timestamp,