(fix) PrometheusServicesLogger _get_metric should return metric in Registry (#6486)

* fix logging DB fails on prometheus

* unit testing log to otel wrapper

* unit testing for service logger + prometheus

* use LATENCY buckets for service logging

* fix service logging

* fix _get_metric in prom services logger

* add clear doc string

* unit testing for prom service logger
This commit is contained in:
Ishaan Jaff 2024-10-29 21:29:19 +05:30 committed by GitHub
parent 8e19a31d36
commit f05bdd4074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 100 additions and 11 deletions

View file

@ -138,6 +138,12 @@ def safe_deep_copy(data):
def log_to_opentelemetry(func):
"""
Decorator to log the duration of a DB related function to ServiceLogger()
Handles logging DB success/failure to ServiceLogger(), which logs to Prometheus, OTEL, Datadog
"""
@wraps(func)
async def wrapper(*args, **kwargs):
start_time: datetime = datetime.now()
@ -145,10 +151,8 @@ def log_to_opentelemetry(func):
try:
result = await func(*args, **kwargs)
end_time: datetime = datetime.now()
from litellm.proxy.proxy_server import proxy_logging_obj
# Log to OTEL only if "parent_otel_span" is in kwargs and is not None
if "PROXY" not in func.__name__:
await proxy_logging_obj.service_logging_obj.async_service_success_hook(
service=ServiceTypes.DB,