From de6330b6b6b892cccc45a288f1fdfce0761a3976 Mon Sep 17 00:00:00 2001 From: Sameer Kankute Date: Tue, 13 Jan 2026 16:59:17 +0530 Subject: [PATCH] Fix test_async_otel_callback[False] --- .../test_otel_logging.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/logging_callback_tests/test_otel_logging.py b/tests/logging_callback_tests/test_otel_logging.py index 3350c6c2db..b53be44fe0 100644 --- a/tests/logging_callback_tests/test_otel_logging.py +++ b/tests/logging_callback_tests/test_otel_logging.py @@ -27,6 +27,9 @@ exporter = InMemorySpanExporter() @pytest.mark.parametrize("streaming", [True, False]) async def test_async_otel_callback(streaming): litellm.set_verbose = True + + # Clear exporter at the start to ensure clean state + exporter.clear() litellm.callbacks = [OpenTelemetry(config=OpenTelemetryConfig(exporter=exporter))] @@ -83,9 +86,9 @@ def validate_litellm_request(span): "llm.user", "gen_ai.response.id", "gen_ai.response.model", - "llm.usage.total_tokens", - "gen_ai.usage.completion_tokens", - "gen_ai.usage.prompt_tokens", + "gen_ai.usage.total_tokens", + "gen_ai.usage.output_tokens", + "gen_ai.usage.input_tokens", ] # get the str of all the span attributes @@ -149,6 +152,10 @@ async def test_awesome_otel_with_message_logging_off(streaming, global_redact): tests when OpenTelemetry(message_logging=False) is set """ litellm.set_verbose = True + + # Clear exporter at the start to ensure clean state + exporter.clear() + litellm.callbacks = [OpenTelemetry(config=OpenTelemetryConfig(exporter=exporter))] if global_redact is False: otel_logger = OpenTelemetry( @@ -201,9 +208,9 @@ def validate_redacted_message_span_attributes(span): "llm.request.type", "gen_ai.response.id", "gen_ai.response.model", - "llm.usage.total_tokens", - "gen_ai.usage.completion_tokens", - "gen_ai.usage.prompt_tokens", + "gen_ai.usage.total_tokens", + "gen_ai.usage.output_tokens", + "gen_ai.usage.input_tokens", ] _all_attributes = set( @@ -230,6 +237,8 @@ def validate_redacted_message_span_attributes(span): attr.startswith("metadata.") or attr.startswith("hidden_params") or attr.startswith("gen_ai.cost.") + or attr.startswith("gen_ai.operation.") + or attr.startswith("gen_ai.request.") ), f"Non-metadata attribute found: {attr}" pass