(Feat) - allow including dd-trace in litellm base image (#7587)

* introduce USE_DDTRACE=true

* update dd tracer

* update

* bump dd trace

* use og slim image

* DD tracing

* fix _init_dd_tracer
This commit is contained in:
Ishaan Jaff 2025-01-06 17:27:09 -08:00 committed by GitHub
parent 1bea935889
commit 89249fcf09
9 changed files with 55 additions and 5 deletions

View file

@ -535,7 +535,13 @@ async def proxy_startup_event(app: FastAPI):
proxy_batch_write_at=proxy_batch_write_at,
proxy_logging_obj=proxy_logging_obj,
)
## [Optional] Initialize dd tracer
ProxyStartupEvent._init_dd_tracer()
# End of startup event
yield
# Shutdown event
await proxy_shutdown_event()
@ -3218,6 +3224,19 @@ class ProxyStartupEvent:
await prisma_client.health_check()
return prisma_client
@classmethod
def _init_dd_tracer(cls):
"""
Initialize dd tracer - if `USE_DDTRACE=true` in .env
DD tracer is used to trace Python applications.
Doc: https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/python/
"""
if get_secret_bool("USE_DDTRACE", False) is True:
import ddtrace
ddtrace.patch_all(logging=True)
#### API ENDPOINTS ####
@router.get(