85742ab165
CPU Test / Lint - next (push) Waiting to run
Dashboard / Chromatic (push) Waiting to run
CPU Test / Lint - fast (push) Waiting to run
CPU Test / Build documentation (push) Waiting to run
CPU Test / Test (Store, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Utilities, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Weave, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (AgentOps, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (LLM proxy, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Others, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Store, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Utilities, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (Weave, stable, Python 3.11) (push) Waiting to run
CPU Test / Test (AgentOps, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (LLM proxy, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Others, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Store, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Utilities, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (Weave, stable, Python 3.12) (push) Waiting to run
CPU Test / Test (AgentOps, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (LLM proxy, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (Others, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (Store, latest, Python 3.13) (push) Waiting to run
CPU Test / Lint - slow (push) Waiting to run
CPU Test / Lint - JavaScript (push) Waiting to run
CPU Test / Test (AgentOps, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (LLM proxy, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Others, legacy, Python 3.10) (push) Waiting to run
CPU Test / Test (Utilities, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (Weave, latest, Python 3.13) (push) Waiting to run
CPU Test / Test (JavaScript) (push) Waiting to run
Deploy Documentation / deploy (push) Has been cancelled
74 lines
2.7 KiB
Python
74 lines
2.7 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
# FIXME: This file will have side-effects on other tests if the tests failed and agentops service is not disabled.
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
from opentelemetry.sdk.metrics.export import MetricExportResult
|
|
from opentelemetry.sdk.trace.export import SpanExportResult
|
|
|
|
from agentlightning.instrumentation.agentops import (
|
|
BypassableAuthenticatedOTLPExporter,
|
|
BypassableOTLPMetricExporter,
|
|
BypassableOTLPSpanExporter,
|
|
enable_agentops_service,
|
|
)
|
|
|
|
|
|
@pytest.mark.agentops
|
|
def test_switchable_authenticated_exporter():
|
|
switchable_authenticated_exporter = BypassableAuthenticatedOTLPExporter(endpoint="http://dummy", jwt="dummy")
|
|
|
|
with patch.object(
|
|
switchable_authenticated_exporter.__class__.__bases__[-1], "export", return_value=SpanExportResult.SUCCESS
|
|
) as mock_export:
|
|
enable_agentops_service()
|
|
result = switchable_authenticated_exporter.export([])
|
|
assert result == SpanExportResult.SUCCESS
|
|
mock_export.assert_called_once()
|
|
|
|
enable_agentops_service(False)
|
|
result = switchable_authenticated_exporter.export([])
|
|
assert result == SpanExportResult.SUCCESS
|
|
assert mock_export.call_count == 1
|
|
|
|
|
|
@pytest.mark.agentops
|
|
def test_switchable_otlp_metric_exporter():
|
|
|
|
switchable_otlp_metric_exporter = BypassableOTLPMetricExporter()
|
|
with patch.object(
|
|
switchable_otlp_metric_exporter.__class__.__bases__[-1], "export", return_value=MetricExportResult.SUCCESS
|
|
) as mock_export:
|
|
enable_agentops_service()
|
|
result = switchable_otlp_metric_exporter.export(metrics_data=MagicMock())
|
|
assert result == MetricExportResult.SUCCESS
|
|
mock_export.assert_called_once()
|
|
|
|
enable_agentops_service(False)
|
|
result = switchable_otlp_metric_exporter.export(metrics_data=MagicMock())
|
|
assert result == MetricExportResult.SUCCESS
|
|
assert mock_export.call_count == 1
|
|
|
|
|
|
@pytest.mark.agentops
|
|
def test_switchable_otlp_span_exporter():
|
|
|
|
switchable_otlp_span_exporter = BypassableOTLPSpanExporter()
|
|
with patch.object(
|
|
# BypassableOTLPSpanExporter is a subclass of LightningStoreOTLPExporter, which is a subclass of OTLPSpanExporter
|
|
switchable_otlp_span_exporter.__class__.__bases__[-1].__bases__[0],
|
|
"export",
|
|
return_value=SpanExportResult.SUCCESS,
|
|
) as mock_export:
|
|
enable_agentops_service()
|
|
result = switchable_otlp_span_exporter.export([])
|
|
assert result == SpanExportResult.SUCCESS
|
|
mock_export.assert_called_once()
|
|
|
|
enable_agentops_service(False)
|
|
result = switchable_otlp_span_exporter.export([])
|
|
assert result == SpanExportResult.SUCCESS
|
|
assert mock_export.call_count == 1
|