-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
feat(prometheus): add api_provider label to token, latency, request and cache metrics #32126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,6 +283,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.END_USER.value, | ||
| UserAPIKeyLabelNames.USER.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
|
Comment on lines
283
to
285
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Rule Used: What: avoid backwards-incompatible changes without... (source) |
||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Adding Other label additions in this codebase (stream label, rate-limit labels) were gated behind Rule Used: What: avoid backwards-incompatible changes without... (source) |
||
| ] | ||
|
Comment on lines
285
to
287
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The project already has an established pattern for exactly this scenario: Rule Used: What: avoid backwards-incompatible changes without... (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| litellm_llm_api_time_to_first_token_metric = [ | ||
|
|
@@ -295,6 +296,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.END_USER.value, | ||
| UserAPIKeyLabelNames.USER.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_request_total_latency_metric = [ | ||
|
|
@@ -307,6 +309,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.USER.value, | ||
| UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_request_queue_time_seconds = [ | ||
|
|
@@ -319,6 +322,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.USER.value, | ||
| UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| # Guardrail metrics - these use custom labels (guardrail_name, status, error_type, hook_type) | ||
|
|
@@ -341,6 +345,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.CLIENT_IP.value, | ||
| UserAPIKeyLabelNames.USER_AGENT.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_proxy_failed_requests_metric = [ | ||
|
|
@@ -362,6 +367,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.CLIENT_IP.value, | ||
| UserAPIKeyLabelNames.USER_AGENT.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_deployment_latency_per_output_token = [ | ||
|
|
@@ -458,6 +464,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.USER_EMAIL.value, | ||
| UserAPIKeyLabelNames.REQUESTED_MODEL.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_total_tokens_metric = [ | ||
|
|
@@ -471,6 +478,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.USER_EMAIL.value, | ||
| UserAPIKeyLabelNames.REQUESTED_MODEL.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_output_tokens_metric = [ | ||
|
|
@@ -484,6 +492,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.USER_EMAIL.value, | ||
| UserAPIKeyLabelNames.REQUESTED_MODEL.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| # Token-type detail metrics — reuse the same label set as | ||
|
|
@@ -682,6 +691,7 @@ class PrometheusMetricLabels: | |
| UserAPIKeyLabelNames.END_USER.value, | ||
| UserAPIKeyLabelNames.USER.value, | ||
| UserAPIKeyLabelNames.MODEL_ID.value, | ||
| UserAPIKeyLabelNames.API_PROVIDER.value, | ||
| ] | ||
|
|
||
| litellm_cache_hits_metric = _cache_metric_labels | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failure path misses provider fields
Medium Severity
_extract_api_provider_from_request_dataonly readscustom_llm_providerfrom nestedlitellm_paramsand from a top-levelstandard_logging_object. On the proxy client failure path,post_call_failure_hookdropslitellm_logging_objwithout copying that payload ontorequest_data, so resolved provider data that still lives on the logging object never reaches the extractor andapi_providercan stay empty when model-name inference fails.Reviewed by Cursor Bugbot for commit be63de1. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out of scope