Skip to content

Commit

Permalink
feat: rename otel: OTELConfig to telemetry in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
teocns committed Jan 7, 2025
1 parent f989ef4 commit d2e319f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def configure(
auto_start_session: Optional[bool] = None,
skip_auto_end_session: Optional[bool] = None,
env_data_opt_out: Optional[bool] = None,
otel: Optional[OTELConfig] = None,
):
if self.has_sessions:
return logger.warning(
Expand All @@ -87,6 +88,7 @@ def configure(
auto_start_session=auto_start_session,
skip_auto_end_session=skip_auto_end_session,
env_data_opt_out=env_data_opt_out,
telemetry=otel,
)

def initialize(self) -> Union[Session, None]:
Expand All @@ -107,7 +109,7 @@ def initialize(self) -> Union[Session, None]:
self._llm_tracker.override_api()

# Initialize telemetry with configuration
self.telemetry.initialize(self._config.otel)
self.telemetry.initialize(self._config.telemetry)

session = None
if self._config.auto_start_session:
Expand Down
8 changes: 4 additions & 4 deletions agentops/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self):
self.auto_start_session: bool = True
self.skip_auto_end_session: bool = False
self.env_data_opt_out: bool = False
self.otel: OTELConfig = OTELConfig() # Default OTEL configuration
self.telemetry: OTELConfig = OTELConfig() # Default OTEL configuration

def configure(
self,
Expand All @@ -32,7 +32,7 @@ def configure(
auto_start_session: Optional[bool] = None,
skip_auto_end_session: Optional[bool] = None,
env_data_opt_out: Optional[bool] = None,
otel: Optional[OTELConfig] = None, # New parameter
telemetry: Optional[OTELConfig] = None, # New parameter
):
if api_key is not None:
try:
Expand Down Expand Up @@ -77,5 +77,5 @@ def configure(
self.env_data_opt_out = env_data_opt_out

# OTEL configuration
if otel is not None:
self.otel = otel
if telemetry is not None:
self.telemetry = telemetry
2 changes: 1 addition & 1 deletion agentops/telemetry/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self):
self._session_exporters: Dict[UUID, ExportManager] = {}
self.config: Optional[OTELConfig] = None

def initialize(self, config: Configuration) -> None:
def initialize(self, config: OTELConfig) -> None:
"""Initialize telemetry components"""
# Check for environment variables if no exporters configured
if not config.otel.additional_exporters:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_telemetry_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def test_configuration_with_otel():
otel_config = OTELConfig(additional_exporters=[exporter])

config = Configuration()
config.configure(None, otel=otel_config)
config.configure(None, telemetry=otel_config)

assert config.otel == otel_config
assert config.otel.additional_exporters == [exporter]
assert config.telemetry == otel_config
assert config.telemetry.additional_exporters == [exporter]


def test_init_accepts_telemetry_config():
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_multiple_exporters_in_config():

telemetry = OTELConfig(additional_exporters=[exporter1, exporter2])
config = Configuration()
config.configure(None, otel=telemetry)
config.configure(None, telemetry=telemetry)

assert len(config.otel.additional_exporters) == 2
assert config.otel.additional_exporters == [exporter1, exporter2]
assert len(config.telemetry.additional_exporters) == 2
assert config.telemetry.additional_exporters == [exporter1, exporter2]

0 comments on commit d2e319f

Please sign in to comment.