Skip to content

Commit

Permalink
refactor(client, session): optional ClientTelemetry, default retrieva…
Browse files Browse the repository at this point in the history
…l from singleton instance
  • Loading branch information
teocns committed Jan 7, 2025
1 parent fb11e95 commit 5fd6131
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5fd6131

Please sign in to comment.