Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions agentops/legacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from agentops.sdk.core import TracingCore
from agentops.semconv.span_kinds import SpanKind
from agentops.exceptions import AgentOpsClientNotInitializedException

_current_session: Optional["Session"] = None


Expand Down Expand Up @@ -95,6 +94,23 @@ def _create_session_span(tags: Union[Dict[str, Any], List[str], None] = None) ->
attributes["tags"] = tags
return _make_span("session", span_kind=SpanKind.SESSION, attributes=attributes)

def _create_session_span(tags: Union[Dict[str, Any], List[str], None] = None) -> tuple:
"""
Helper function to create a session span with tags.

Args:
tags: Optional tags to attach to the span

Returns:
A tuple of (span, context, token)
"""
from agentops.sdk.decorators.utility import _make_span

attributes = {}
if tags:
attributes["tags"] = tags
return _make_span("session", span_kind=SpanKind.SESSION, attributes=attributes)


def start_session(
tags: Union[Dict[str, Any], List[str], None] = None,
Expand Down Expand Up @@ -152,7 +168,6 @@ def _set_span_attributes(span: Any, attributes: Dict[str, Any]) -> None:
for key, value in attributes.items():
span.set_attribute(f"agentops.status.{key}", str(value))


def _flush_span_processors() -> None:
"""
Helper to force flush all span processors.
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_session_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def test_session_auto_start(instrumentation):

# Pass a dummy API key for the test
session = agentops.init(api_key="test-api-key", auto_start_session=True)

assert isinstance(session, Session)


Expand Down Expand Up @@ -157,4 +156,4 @@ def test_crewai_kwargs_force_flush():
)

# Explicitly ensure the core isn't already shut down for the test
assert TracingCore.get_instance()._initialized, "TracingCore should still be initialized"
assert TracingCore.get_instance()._initialized, "TracingCore should still be initialized"
1 change: 1 addition & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading