forked from phoenix/litellm-mirror
use type for DatadogProxyFailureHookJsonMessage
This commit is contained in:
parent
86d76dc1d4
commit
6586718b61
2 changed files with 15 additions and 10 deletions
|
@ -35,7 +35,7 @@ from litellm.llms.custom_httpx.http_handler import (
|
||||||
from litellm.proxy._types import UserAPIKeyAuth
|
from litellm.proxy._types import UserAPIKeyAuth
|
||||||
from litellm.types.services import ServiceLoggerPayload
|
from litellm.types.services import ServiceLoggerPayload
|
||||||
|
|
||||||
from .types import DD_ERRORS, DatadogPayload, DataDogStatus
|
from .types import *
|
||||||
from .utils import make_json_serializable
|
from .utils import make_json_serializable
|
||||||
|
|
||||||
DD_MAX_BATCH_SIZE = 1000 # max number of logs DD API can accept
|
DD_MAX_BATCH_SIZE = 1000 # max number of logs DD API can accept
|
||||||
|
@ -410,11 +410,13 @@ class DataDogLogger(CustomBatchLogger):
|
||||||
"Datadog: Logging - Enters failure logging function for model %s",
|
"Datadog: Logging - Enters failure logging function for model %s",
|
||||||
request_data,
|
request_data,
|
||||||
)
|
)
|
||||||
_json_message = {
|
_json_message = DatadogProxyFailureHookJsonMessage(
|
||||||
"exception": str(original_exception),
|
exception=str(original_exception),
|
||||||
"request_data": request_data,
|
traceback=traceback.format_exc(),
|
||||||
"user_api_key_dict": user_api_key_dict.model_dump(),
|
request_data=request_data,
|
||||||
}
|
user_api_key_dict=user_api_key_dict.model_dump(),
|
||||||
|
)
|
||||||
|
|
||||||
dd_payload = DatadogPayload(
|
dd_payload = DatadogPayload(
|
||||||
ddsource=DD_SOURCE_NAME,
|
ddsource=DD_SOURCE_NAME,
|
||||||
ddtags="",
|
ddtags="",
|
||||||
|
@ -428,10 +430,6 @@ class DataDogLogger(CustomBatchLogger):
|
||||||
verbose_logger.debug(
|
verbose_logger.debug(
|
||||||
f"Datadog, failure event added to queue. Will flush in {self.flush_interval} seconds..."
|
f"Datadog, failure event added to queue. Will flush in {self.flush_interval} seconds..."
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(self.log_queue) >= self.batch_size:
|
|
||||||
await self.async_send_batch()
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
verbose_logger.exception(
|
verbose_logger.exception(
|
||||||
f"Datadog Layer Error - {str(e)}\n{traceback.format_exc()}"
|
f"Datadog Layer Error - {str(e)}\n{traceback.format_exc()}"
|
||||||
|
|
|
@ -19,3 +19,10 @@ class DatadogPayload(TypedDict, total=False):
|
||||||
|
|
||||||
class DD_ERRORS(Enum):
|
class DD_ERRORS(Enum):
|
||||||
DATADOG_413_ERROR = "Datadog API Error - Payload too large (batch is above 5MB uncompressed). If you want this logged either disable request/response logging or set `DD_BATCH_SIZE=50`"
|
DATADOG_413_ERROR = "Datadog API Error - Payload too large (batch is above 5MB uncompressed). If you want this logged either disable request/response logging or set `DD_BATCH_SIZE=50`"
|
||||||
|
|
||||||
|
|
||||||
|
class DatadogProxyFailureHookJsonMessage(TypedDict, total=False):
|
||||||
|
exception: str
|
||||||
|
traceback: str
|
||||||
|
request_data: dict
|
||||||
|
user_api_key_dict: dict
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue