mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
(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:
parent
8e19a31d36
commit
f05bdd4074
4 changed files with 100 additions and 11 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue