mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
feat - log DB exceptions to OTEL
This commit is contained in:
parent
f152b5eb1d
commit
ac722d02ce
1 changed files with 40 additions and 20 deletions
|
@ -97,6 +97,8 @@ def log_to_opentelemetry(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
async def wrapper(*args, **kwargs):
|
async def wrapper(*args, **kwargs):
|
||||||
start_time = datetime.now()
|
start_time = datetime.now()
|
||||||
|
|
||||||
|
try:
|
||||||
result = await func(*args, **kwargs)
|
result = await func(*args, **kwargs)
|
||||||
end_time = datetime.now()
|
end_time = datetime.now()
|
||||||
|
|
||||||
|
@ -118,6 +120,24 @@ def log_to_opentelemetry(func):
|
||||||
)
|
)
|
||||||
# end of logging to otel
|
# end of logging to otel
|
||||||
return result
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
end_time = datetime.now()
|
||||||
|
if (
|
||||||
|
"parent_otel_span" in kwargs
|
||||||
|
and kwargs["parent_otel_span"] is not None
|
||||||
|
and "proxy_logging_obj" in kwargs
|
||||||
|
and kwargs["proxy_logging_obj"] is not None
|
||||||
|
):
|
||||||
|
proxy_logging_obj = kwargs["proxy_logging_obj"]
|
||||||
|
await proxy_logging_obj.service_logging_obj.async_service_failure_hook(
|
||||||
|
error=e,
|
||||||
|
service=ServiceTypes.DB,
|
||||||
|
call_type=func.__name__,
|
||||||
|
duration=0.0,
|
||||||
|
start_time=start_time,
|
||||||
|
end_time=end_time,
|
||||||
|
)
|
||||||
|
raise e
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue