From fd7014a326c94090e6a5fe4863293acc2bb84795 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sun, 6 Oct 2024 13:48:30 +0530 Subject: [PATCH] correct use of healthy / unhealthy --- docs/my-website/docs/proxy/team_logging.md | 2 +- litellm/proxy/_types.py | 4 ++-- .../management_endpoints/key_management_endpoints.py | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/my-website/docs/proxy/team_logging.md b/docs/my-website/docs/proxy/team_logging.md index 3221100bef9..62d22588277 100644 --- a/docs/my-website/docs/proxy/team_logging.md +++ b/docs/my-website/docs/proxy/team_logging.md @@ -338,7 +338,7 @@ Response when logging callbacks are setup correctly: Response when logging callbacks are not setup correctly: ```json { - "key": "healthy", + "key": "unhealthy", "logging_callbacks": { "callbacks": [ "gcs_bucket" diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index c3b9bc00cc5..36489f8a438 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -1927,10 +1927,10 @@ class CurrentItemRateLimit(TypedDict): class LoggingCallbackStatus(TypedDict, total=False): callbacks: List[str] - status: str + status: Literal["healthy", "unhealthy"] details: Optional[str] class KeyHealthResponse(TypedDict, total=False): - key: str + key: Literal["healthy", "unhealthy"] logging_callbacks: Optional[LoggingCallbackStatus] diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index 133affa8c55..152de4edf7c 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -1496,7 +1496,7 @@ async def key_health( Response when logging callbacks are not setup correctly: ```json { - "key": "healthy", + "key": "unhealthy", "logging_callbacks": { "callbacks": [ "gcs_bucket" @@ -1525,6 +1525,10 @@ async def key_health( ) health_status["logging_callbacks"] = logging_statuses + # Check if any logging callback is unhealthy + if logging_statuses.get("status") == "unhealthy": + health_status["key"] = "unhealthy" + return KeyHealthResponse(**health_status) except Exception as e: @@ -1591,7 +1595,7 @@ async def test_key_logging( except Exception as e: return LoggingCallbackStatus( callbacks=logging_callbacks, - status="error", + status="unhealthy", details=f"Logging test failed: {str(e)}", )