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
test_proxy_success_metrics
Ishaan Jaffer92c8e00520b8
diff --git a/tests/otel_tests/test_prometheus.py b/tests/otel_tests/test_prometheus.pyindex 97a61d92c7f..09ae7d5a3d0 100644--- a/tests/otel_tests/test_prometheus.py+++ b/tests/otel_tests/test_prometheus.py@@ -169,16 +169,33 @@ async def test_proxy_success_metrics():assert END_USER_ID not in metrics- # Check if the success metric is present and correct- assert (- 'litellm_request_total_latency_metric_bucket{api_key_alias="None",end_user="None",hashed_api_key="88dc28d0f030c55ed4ab77ed8faf098196cb1c05df778539800c9f1243fe6b4b",le="0.005",model="fake",requested_model="fake-openai-endpoint",team="None",team_alias="None",user="*******_user_id"}'- in metrics- )+ # Check if the success metric is present and correct - use flexible matching+ # Check for request_total_latency_metric with required fields+ # Note: The model can be "gpt-3.5-turbo-0301" or similar depending on what's returned+ found_request_latency = False+ for line in metrics.split("\n"):+ if 'litellm_request_total_latency_metric_bucket{' in line and \+ 'api_key_alias="None"' in line and \+ 'hashed_api_key="88dc28d0f030c55ed4ab77ed8faf098196cb1c05df778539800c9f1243fe6b4b"' in line and \+ 'requested_model="fake-openai-endpoint"' in line and \+ 'le="0.005"' in line:+ found_request_latency = True+ break++ assert found_request_latency, "Expected litellm_request_total_latency_metric_bucket not found in /metrics"- assert (- 'litellm_llm_api_latency_metric_bucket{api_key_alias="None",end_user="None",hashed_api_key="88dc28d0f030c55ed4ab77ed8faf098196cb1c05df778539800c9f1243fe6b4b",le="0.005",model="fake",requested_model="fake-openai-endpoint",team="None",team_alias="None",user="*******_user_id"}'- in metrics- )+ # Check for llm_api_latency_metric with required fields+ found_api_latency = False+ for line in metrics.split("\n"):+ if 'litellm_llm_api_latency_metric_bucket{' in line and \+ 'api_key_alias="None"' in line and \+ 'hashed_api_key="88dc28d0f030c55ed4ab77ed8faf098196cb1c05df778539800c9f1243fe6b4b"' in line and \+ 'requested_model="fake-openai-endpoint"' in line and \+ 'le="0.005"' in line:+ found_api_latency = True+ break++ assert found_api_latency, "Expected litellm_llm_api_latency_metric_bucket not found in /metrics"verify_latency_metrics(metrics)