From 5fd61318eeb0b314274db94ba668d72cacc98062 Mon Sep 17 00:00:00 2001 From: Teo Date: Tue, 7 Jan 2025 11:36:11 +0100 Subject: [PATCH] refactor(client, session): optional ClientTelemetry, default retrieval from singleton instance --- agentops/client.py | 1 + agentops/session.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/agentops/client.py b/agentops/client.py index 5c617c7b..fafd59f2 100644 --- a/agentops/client.py +++ b/agentops/client.py @@ -236,6 +236,7 @@ def start_session( session_tags.update(tags) session = Session( + client=self._telemetry, session_id=session_id, tags=list(session_tags), host_env=self.host_env, diff --git a/agentops/session.py b/agentops/session.py index 86a153fb..f799f6b1 100644 --- a/agentops/session.py +++ b/agentops/session.py @@ -201,7 +201,7 @@ def __init__( self, session_id: UUID, config: Configuration, - client: ClientTelemetry, + client: Optional[ClientTelemetry] = None, # Not mandatory, we can use the Client singleton to retrieve the telemetry client tags: Optional[List[str]] = None, host_env: Optional[dict] = None, ): @@ -233,6 +233,7 @@ def __init__( if not self.is_running: return + client = client or Client()._telemetry # Get session-specific tracer from client telemetry self._otel_tracer = client.get_session_tracer( session_id=self.session_id, config=self.config, jwt=self.jwt