Skip to content

Commit

Permalink
fix: span event to dict conversion (#3009)
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHYang committed Apr 26, 2024
1 parent a41affb commit 3c73f03
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/phoenix/db/bulk_inserter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import logging
from dataclasses import asdict
from datetime import datetime, timezone
from itertools import islice
from time import time
Expand Down Expand Up @@ -295,7 +296,7 @@ async def _insert_span(session: AsyncSession, span: Span, project_name: str) ->
start_time=span.start_time,
end_time=span.end_time,
attributes=span.attributes,
events=span.events,
events=[asdict(event) for event in span.events],
status_code=span.status_code.value,
status_message=span.status_message,
cumulative_error_count=cumulative_error_count,
Expand Down
2 changes: 1 addition & 1 deletion src/phoenix/server/api/types/Span.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def from_dict(
return SpanEvent(
name=event["name"],
message=cast(str, event["attributes"].get(trace_schema.EXCEPTION_MESSAGE) or ""),
timestamp=event["timestamp"],
timestamp=datetime.fromisoformat(event["timestamp"]),
)


Expand Down
4 changes: 2 additions & 2 deletions src/phoenix/trace/schemas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dataclasses import dataclass
from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Mapping, NamedTuple, Optional
from typing import Any, List, Mapping, NamedTuple, Optional
from uuid import UUID

EXCEPTION_TYPE = "exception.type"
Expand Down Expand Up @@ -71,7 +71,7 @@ class SpanConversationAttributes:


@dataclass(frozen=True)
class SpanEvent(Dict[str, Any]):
class SpanEvent:
"""
A Span Event can be thought of as a structured log message (or annotation)
on a Span, typically used to denote a meaningful, singular point in time
Expand Down

0 comments on commit 3c73f03

Please sign in to comment.