Skip to content

Commit

Permalink
refactor: rename GenericAdapter to SessionSpanAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
teocns committed Nov 27, 2024
1 parent 36a725e commit 6b30e1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions agentops/session/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def encode_event(obj: Any) -> Dict[str, Any]:
return obj


class GenericAdapter:
class SessionSpanAdapter:
"""Adapts any object to a dictionary of span attributes"""

@staticmethod
Expand Down Expand Up @@ -207,7 +207,7 @@ def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:
events = []
for span in spans:
# Convert span attributes to event using adapter
event = GenericAdapter.from_span_attributes(span.attributes or {})
event = SessionSpanAdapter.from_span_attributes(span.attributes or {})
# Add session ID
event["session_id"] = str(self.session.session_id)
events.append(event)
Expand Down Expand Up @@ -313,7 +313,7 @@ def _record_otel_event(self, event: Union[Event, ErrorEvent], flush_now: bool =
) as span:
try:
# Use GenericAdapter to convert event to span attributes
span_attributes = GenericAdapter.to_span_attributes(event)
span_attributes = SessionSpanAdapter.to_span_attributes(event)
span.set_attributes(span_attributes)
except Exception as e:
# Set error status on span and re-raise
Expand Down
6 changes: 3 additions & 3 deletions tests/session/test_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_generic_adapter_conversion(session):
from datetime import datetime
from uuid import UUID

from agentops.session.exporter import GenericAdapter
from agentops.session.exporter import SessionSpanAdapter
from agentops.event import ActionEvent

# Create a test event with various attribute types
Expand All @@ -51,7 +51,7 @@ def test_generic_adapter_conversion(session):
test_event.session_id = session.session_id

# Test conversion to span attributes
span_attrs = GenericAdapter.to_span_attributes(test_event)
span_attrs = SessionSpanAdapter.to_span_attributes(test_event)

# Verify basic attribute conversion
assert span_attrs["event.type"] == "actions"
Expand All @@ -76,7 +76,7 @@ def test_generic_adapter_conversion(session):
assert span_attrs["session.id"] == str(session.session_id)

# Test conversion back from span attributes
event_attrs = GenericAdapter.from_span_attributes(span_attrs)
event_attrs = SessionSpanAdapter.from_span_attributes(span_attrs)

# Verify event structure
assert event_attrs["event_type"] == "actions"
Expand Down

0 comments on commit 6b30e1f

Please sign in to comment.