forked from phoenix/litellm-mirror
Merge pull request #5422 from BerriAI/fix_promt
[minor fix Proxy] - prometheus - safe update start / end time
This commit is contained in:
commit
f5a8f71080
1 changed files with 11 additions and 7 deletions
|
@ -349,19 +349,23 @@ class PrometheusLogger(CustomLogger):
|
|||
# latency metrics
|
||||
total_time: timedelta = kwargs.get("end_time") - kwargs.get("start_time")
|
||||
total_time_seconds = total_time.total_seconds()
|
||||
api_call_total_time: timedelta = kwargs.get("end_time") - kwargs.get(
|
||||
"api_call_start_time"
|
||||
)
|
||||
api_call_start_time = kwargs.get("api_call_start_time", None)
|
||||
|
||||
api_call_total_time_seconds = api_call_total_time.total_seconds()
|
||||
if api_call_start_time is not None and isinstance(
|
||||
api_call_start_time, datetime
|
||||
):
|
||||
api_call_total_time: timedelta = (
|
||||
kwargs.get("end_time") - api_call_start_time
|
||||
)
|
||||
api_call_total_time_seconds = api_call_total_time.total_seconds()
|
||||
self.litellm_llm_api_latency_metric.labels(model).observe(
|
||||
api_call_total_time_seconds
|
||||
)
|
||||
|
||||
# log metrics
|
||||
self.litellm_request_total_latency_metric.labels(model).observe(
|
||||
total_time_seconds
|
||||
)
|
||||
self.litellm_llm_api_latency_metric.labels(model).observe(
|
||||
api_call_total_time_seconds
|
||||
)
|
||||
|
||||
# set x-ratelimit headers
|
||||
if premium_user is True:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue