mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
add callback duration header, size-gate debug logging, detailed timing headers
This commit is contained in:
parent
60848b5ff3
commit
0dc2b88c53
1 changed files with 28 additions and 5 deletions
|
|
@ -24,6 +24,8 @@ from litellm._logging import verbose_proxy_logger
|
|||
from litellm._uuid import uuid
|
||||
from litellm.constants import (
|
||||
DD_TRACER_STREAMING_CHUNK_YIELD_RESOURCE,
|
||||
LITELLM_DETAILED_TIMING,
|
||||
MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG,
|
||||
STREAM_SSE_DATA_PREFIX,
|
||||
)
|
||||
from litellm.litellm_core_utils.dd_tracing import tracer
|
||||
|
|
@ -434,6 +436,19 @@ class ProxyBaseLLMRequestProcessing:
|
|||
"x-litellm-overhead-duration-ms": str(
|
||||
hidden_params.get("litellm_overhead_time_ms", None)
|
||||
),
|
||||
"x-litellm-callback-duration-ms": str(
|
||||
hidden_params.get("callback_duration_ms", None)
|
||||
),
|
||||
**(
|
||||
{
|
||||
"x-litellm-timing-pre-processing-ms": str(hidden_params.get("timing_pre_processing_ms", None)),
|
||||
"x-litellm-timing-llm-api-ms": str(hidden_params.get("timing_llm_api_ms", None)),
|
||||
"x-litellm-timing-post-processing-ms": str(hidden_params.get("timing_post_processing_ms", None)),
|
||||
"x-litellm-timing-message-copy-ms": str(hidden_params.get("timing_message_copy_ms", None)),
|
||||
}
|
||||
if LITELLM_DETAILED_TIMING
|
||||
else {}
|
||||
),
|
||||
"x-litellm-fastest_response_batch_completion": (
|
||||
str(fastest_response_batch_completion)
|
||||
if fastest_response_batch_completion is not None
|
||||
|
|
@ -753,11 +768,19 @@ class ProxyBaseLLMRequestProcessing:
|
|||
self.data.get("model") if isinstance(self.data.get("model"), str) else None
|
||||
)
|
||||
if verbose_proxy_logger.isEnabledFor(logging.DEBUG):
|
||||
verbose_proxy_logger.debug(
|
||||
"Request received by LiteLLM:\n{}".format(
|
||||
json.dumps(self.data, indent=4, default=str)
|
||||
),
|
||||
)
|
||||
_payload_str = json.dumps(self.data, default=str)
|
||||
if len(_payload_str) > MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG:
|
||||
verbose_proxy_logger.debug(
|
||||
"Request received by LiteLLM: payload too large to log (%d bytes, limit %d). Keys: %s",
|
||||
len(_payload_str),
|
||||
MAX_PAYLOAD_SIZE_FOR_DEBUG_LOG,
|
||||
list(self.data.keys()) if isinstance(self.data, dict) else type(self.data).__name__,
|
||||
)
|
||||
else:
|
||||
verbose_proxy_logger.debug(
|
||||
"Request received by LiteLLM:\n%s",
|
||||
json.dumps(self.data, indent=4, default=str),
|
||||
)
|
||||
|
||||
self.data, logging_obj = await self.common_processing_pre_call_logic(
|
||||
request=request,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue