The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix otel load test
Ishaan Jaff88706488f913
diff --git a/tests/load_tests/test_otel_load_test.py b/tests/load_tests/test_otel_load_test.pyindex 1a7b83f5a86..f0f4d959ad5 100644--- a/tests/load_tests/test_otel_load_test.py+++ b/tests/load_tests/test_otel_load_test.py@@ -13,48 +13,37 @@ import pytestdef test_otel_logging_async():- # this tests time added to make otel logging calls, vs just acompletion callstry:-os.environ["OTEL_EXPORTER"] = "otlp_http"os.environ["OTEL_ENDPOINT"] = ("https://exampleopenaiendpoint-production.up.railway.app/traces")os.environ["OTEL_HEADERS"] = "Authorization=K0BSwd"- # Make 5 calls with an empty success_callback- litellm.success_callback = []- litellm.callbacks = []- litellm._async_success_callback = []- litellm._async_failure_callback = []- litellm._async_failure_callback = []- litellm.failure_callback = []- start_time_empty_callback = asyncio.run(make_async_calls())- print("done with no callback test")-- print("starting otel test")- # Make 5 calls with success_callback set to "otel"- litellm.callbacks = ["otel"]- start_time_otel = asyncio.run(make_async_calls())- print("done with otel test")-- # Compare the time for both scenarios- print(f"Time taken with success_callback='otel': {start_time_otel}")- print(f"Time taken with empty success_callback: {start_time_empty_callback}")-- # Calculate the percentage difference- percentage_diff = (- abs(start_time_otel - start_time_empty_callback)- / start_time_empty_callback- * 100- )+ def single_run():+ litellm.callbacks = []+ start_time_empty = asyncio.run(make_async_calls())+ print(f"Time with empty callback: {start_time_empty}")- # Assert that the difference is not more than 10%- assert (- percentage_diff < 10- ), f"Performance difference of {percentage_diff:.2f}% exceeds 10% threshold"+ litellm.callbacks = ["otel"]+ start_time_otel = asyncio.run(make_async_calls())+ print(f"Time with otel callback: {start_time_otel}")++ percent_diff = (+ abs(start_time_otel - start_time_empty) / start_time_empty * 100+ )+ print(f"Run performance difference: {percent_diff:.2f}%")+ return percent_diff- print(f"Performance difference: {percentage_diff:.2f}%")+ percent_diffs = [single_run() for _ in range(3)]+ avg_percent_diff = sum(percent_diffs) / len(percent_diffs)++ print(f"Percentage differences: {percent_diffs}")+ print(f"Average performance difference: {avg_percent_diff:.2f}%")++ assert (+ avg_percent_diff < 10+ ), f"Average performance difference of {avg_percent_diff:.2f}% exceeds 10% threshold"except litellm.Timeout as e:pass