Litellm dev 12 25 2024 p3 (#7421)

* refactor(prometheus.py): refactor to use a factory method for setting label values

allows for enforcing end user id disabling on prometheus e2e

* fix: fix linting error

* fix(prometheus.py): ensure label factory drops end-user value if disabled by user

* fix(prometheus.py): specify service_type in end user tracking get

* test: fix test

* test: add unit test for prometheus factory

* test: improve test (cover flag not set scenario)

* test(test_prometheus.py): e2e test covering if 'end_user_id' shows up in testing if disabled

scrapes the `/metrics` endpoint and scans text to check if id appears in emitted metrics

* fix(prometheus.py): stringify status code before logging it
This commit is contained in:
Krish Dholakia 2024-12-25 18:54:24 -08:00 committed by GitHub
parent 760328b6ad
commit 21e8f212d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 223 additions and 90 deletions

View file

@ -12,7 +12,7 @@ import time
import traceback
import uuid
from datetime import datetime as dt_object
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union, cast
from pydantic import BaseModel
@ -2983,6 +2983,7 @@ def get_standard_logging_object_payload(
cache_hit=cache_hit,
stream=stream,
status=status,
custom_llm_provider=cast(Optional[str], kwargs.get("custom_llm_provider")),
saved_cache_cost=saved_cache_cost,
startTime=start_time_float,
endTime=end_time_float,