Skip to content

Commit 1543515

Browse files
author
Hao Ni (CSI Interfusion Co Ltd)
committed
fix import name issue
1 parent 10b9fef commit 1543515

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

agentlightning/instrumentation/agentops.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import logging
6-
from typing import Any, Callable, cast
6+
from typing import Any, Callable
77

88
import requests
99
from agentops.client.api import V3Client, V4Client
@@ -38,7 +38,7 @@ def enable_agentops_service(enabled: bool = True) -> None:
3838
"""
3939
global _agentops_service_enabled
4040
_agentops_service_enabled = enabled
41-
logger.info(f"Switch set to {value} for exporters and clients.")
41+
logger.info(f"Switch set to {enabled} for exporters and clients.")
4242

4343

4444
def _patch_exporters():
@@ -265,8 +265,7 @@ class SwitchableV3Client(V3Client):
265265

266266
def fetch_auth_token(self, *args: Any, **kwargs: Any) -> AuthTokenResponse:
267267
if _agentops_service_enabled:
268-
resp = super().post(*args, **kwargs)
269-
return cast(AuthTokenResponse, resp)
268+
return super().fetch_auth_token(*args, **kwargs)
270269
else:
271270
logger.debug("SwitchableV3Client is switched off, skipping fetch_auth_token request.")
272271
return AuthTokenResponse(token="dummy", project_id="dummy")

tests/instrumentation/test_agentops.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
SwitchableAuthenticatedOTLPExporter,
1010
SwitchableOTLPMetricExporter,
1111
SwitchableOTLPSpanExporter,
12-
set_switch,
12+
enable_agentops_service,
1313
)
1414

1515

@@ -19,12 +19,12 @@ def test_switchable_authenticated_exporter():
1919
with patch.object(
2020
switchable_authenticated_exporter.__class__.__bases__[0], "export", return_value=SpanExportResult.SUCCESS
2121
) as mock_export:
22-
set_switch(True)
22+
enable_agentops_service()
2323
result = switchable_authenticated_exporter.export([])
2424
assert result == SpanExportResult.SUCCESS
2525
mock_export.assert_called_once()
2626

27-
set_switch(False)
27+
enable_agentops_service(False)
2828
result = switchable_authenticated_exporter.export([])
2929
assert result == SpanExportResult.SUCCESS
3030
assert mock_export.call_count == 1
@@ -36,12 +36,12 @@ def test_switchable_otlp_metric_exporter():
3636
with patch.object(
3737
switchable_otlp_metric_exporter.__class__.__bases__[0], "export", return_value=MetricExportResult.SUCCESS
3838
) as mock_export:
39-
set_switch(True)
39+
enable_agentops_service()
4040
result = switchable_otlp_metric_exporter.export(metrics_data=MagicMock())
4141
assert result == MetricExportResult.SUCCESS
4242
mock_export.assert_called_once()
4343

44-
set_switch(False)
44+
enable_agentops_service(False)
4545
result = switchable_otlp_metric_exporter.export(metrics_data=MagicMock())
4646
assert result == MetricExportResult.SUCCESS
4747
assert mock_export.call_count == 1
@@ -53,12 +53,12 @@ def test_switchable_otlp_span_exporter():
5353
with patch.object(
5454
switchable_otlp_span_exporter.__class__.__bases__[0], "export", return_value=SpanExportResult.SUCCESS
5555
) as mock_export:
56-
set_switch(True)
56+
enable_agentops_service()
5757
result = switchable_otlp_span_exporter.export([])
5858
assert result == SpanExportResult.SUCCESS
5959
mock_export.assert_called_once()
6060

61-
set_switch(False)
61+
enable_agentops_service(False)
6262
result = switchable_otlp_span_exporter.export([])
6363
assert result == SpanExportResult.SUCCESS
6464
assert mock_export.call_count == 1

0 commit comments

Comments
 (0)