Skip to content

Commit

Permalink
allow host env opt out (#174)
Browse files Browse the repository at this point in the history
* allow host env opt out

* still get sdk and os

* use env var

* use env var
  • Loading branch information
bboynton97 authored May 2, 2024
1 parent d1bbee4 commit c229b70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 4 additions & 2 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Classes:
Client: Provides methods to interact with the AgentOps service.
"""

import os
from .event import ActionEvent, ErrorEvent, Event
from .enums import EndState
from .helpers import get_ISO_time, singleton, check_call_stack_for_agent_id
Expand Down Expand Up @@ -76,6 +76,8 @@ def __init__(self,
self._session = None
self._worker = None

self._env_data_opt_out = os.getenv('AGENTOPS_ENV_DATA_OPT_OUT') and os.getenv('AGENTOPS_ENV_DATA_OPT_OUT').lower() == 'true'

try:
self.config = Configuration(api_key=api_key,
parent_key=parent_key,
Expand Down Expand Up @@ -236,7 +238,7 @@ def start_session(self, tags: Optional[List[str]] = None, config: Optional[Confi
if not config and not self.config:
return logger.warning("🖇 AgentOps: Cannot start session - missing configuration")

self._session = Session(inherited_session_id or uuid4(), tags or self._tags_for_future_session, host_env=get_host_env())
self._session = Session(inherited_session_id or uuid4(), tags or self._tags_for_future_session, host_env=get_host_env(self._env_data_opt_out))
self._worker = Worker(config or self.config)
start_session_result = self._worker.start_session(self._session)
if not start_session_result:
Expand Down
22 changes: 14 additions & 8 deletions agentops/host_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,17 @@ def get_disk_details():
return disk_info


def get_host_env():
return {
"SDK": get_sdk_details(),
"OS": get_os_details(),
"CPU": get_cpu_details(),
"RAM": get_ram_details(),
"Disk": get_disk_details(),
}
def get_host_env(opt_out: bool = False):
if opt_out:
return {
"SDK": get_sdk_details(),
"OS": get_os_details()
}
else:
return {
"SDK": get_sdk_details(),
"OS": get_os_details(),
"CPU": get_cpu_details(),
"RAM": get_ram_details(),
"Disk": get_disk_details(),
}

0 comments on commit c229b70

Please sign in to comment.