forked from phoenix/litellm-mirror
add new dd type for auth errors
This commit is contained in:
parent
aea68cbeb6
commit
1f5c972985
3 changed files with 44 additions and 2 deletions
|
@ -32,6 +32,8 @@ from litellm.llms.custom_httpx.http_handler import (
|
|||
get_async_httpx_client,
|
||||
httpxSpecialProvider,
|
||||
)
|
||||
from litellm.proxy._types import UserAPIKeyAuth
|
||||
from litellm.types.integrations.datadog import *
|
||||
from litellm.types.services import ServiceLoggerPayload
|
||||
from litellm.types.utils import StandardLoggingPayload
|
||||
|
||||
|
@ -364,6 +366,38 @@ class DataDogLogger(CustomBatchLogger):
|
|||
"""
|
||||
return
|
||||
|
||||
async def async_post_call_failure_hook(
|
||||
self,
|
||||
request_data: dict,
|
||||
original_exception: Exception,
|
||||
user_api_key_dict: UserAPIKeyAuth,
|
||||
):
|
||||
"""
|
||||
Handles Proxy Errors (not-related to LLM API), ex: Authentication Errors
|
||||
"""
|
||||
import json
|
||||
|
||||
_exception_payload = DatadogProxyFailureHookJsonMessage(
|
||||
exception=str(original_exception),
|
||||
error_class=str(original_exception.__class__.__name__),
|
||||
status_code=getattr(original_exception, "status_code", None),
|
||||
traceback=traceback.format_exc(),
|
||||
user_api_key_dict=user_api_key_dict.model_dump(),
|
||||
)
|
||||
|
||||
json_payload = json.dumps(_exception_payload)
|
||||
verbose_logger.debug("Datadog: Logger - Logging payload = %s", json_payload)
|
||||
dd_payload = DatadogPayload(
|
||||
ddsource=os.getenv("DD_SOURCE", "litellm"),
|
||||
ddtags="",
|
||||
hostname="",
|
||||
message=json_payload,
|
||||
service="litellm-server",
|
||||
status=DataDogStatus.ERROR,
|
||||
)
|
||||
|
||||
self.log_queue.append(dd_payload)
|
||||
|
||||
def _create_v0_logging_payload(
|
||||
self,
|
||||
kwargs: Union[dict, Any],
|
||||
|
|
|
@ -2032,7 +2032,6 @@
|
|||
"tool_use_system_prompt_tokens": 264,
|
||||
"supports_assistant_prefill": true,
|
||||
"supports_prompt_caching": true,
|
||||
"supports_pdf_input": true,
|
||||
"supports_response_schema": true
|
||||
},
|
||||
"claude-3-opus-20240229": {
|
||||
|
@ -2098,6 +2097,7 @@
|
|||
"supports_vision": true,
|
||||
"tool_use_system_prompt_tokens": 159,
|
||||
"supports_assistant_prefill": true,
|
||||
"supports_pdf_input": true,
|
||||
"supports_prompt_caching": true,
|
||||
"supports_response_schema": true
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from enum import Enum
|
||||
from typing import TypedDict
|
||||
from typing import Optional, TypedDict
|
||||
|
||||
|
||||
class DataDogStatus(str, Enum):
|
||||
|
@ -19,3 +19,11 @@ class DatadogPayload(TypedDict, total=False):
|
|||
|
||||
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`"
|
||||
|
||||
|
||||
class DatadogProxyFailureHookJsonMessage(TypedDict, total=False):
|
||||
exception: str
|
||||
error_class: str
|
||||
status_code: Optional[int]
|
||||
traceback: str
|
||||
user_api_key_dict: dict
|
Loading…
Add table
Add a link
Reference in a new issue