BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
14.07k stars 1.66k forks source link

(fix) Strip trailing slash in api_base for prometheus metrics #6859

Open owaisaamir opened 10 hours ago

owaisaamir commented 10 hours ago

Description by Korbit AI

What change is being made?

Remove trailing slashes from api_base in the prometheus metrics

Why are these changes being made?

Trailing slashes in api_base values can cause increased metric cardinality resulting in higher custom metrics cost in platform such as Datadog. This can also cause metrics not getting aggregated correctly for the same api_base.

example metrics with trailing slash:

litellm_deployment_success_responses_total{api_base="https://api.openai.com/v1/",api_key_alias="None",api_provider="openai",hashed_api_key="None",litellm_model_name="gpt-4o",model_id="0816ddaaddd6d762d4ba80f754895c0386360bdecc35430e5644bba7eb905b4f",requested_model="openai-gpt-4o",team="None",team_alias="None"} 4.0
litellm_deployment_success_responses_total{api_base="https://my-test-instance.openai.azure.com//openai/",api_key_alias="None",api_provider="azure",hashed_api_key="None",litellm_model_name="gpt-4o",model_id="4346bb17b8f946ed63b7a315d50b765be26387b0ffe3f1875c37a1efdcf0e82e",requested_model="azure-gpt-4o",team="None",team_alias="None"} 3.0
litellm_deployment_success_responses_total{api_base="https://api.openai.com/v1",api_key_alias="None",api_provider="openai",hashed_api_key="EMPTY",litellm_model_name="gpt-4o",model_id="0816ddaaddd6d762d4ba80f754895c0386360bdecc35430e5644bba7eb905b4f",requested_model="openai-gpt-4o",team="None",team_alias="None"} 1.0

By stripping trailing slashes, this improves metrics aggregation and reduces custom metrics cost.

Is this description stale? Ask me to generate a new description by commenting /korbit-generate-pr-description

vercel[bot] commented 10 hours ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 10:38pm