mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
Add timeout to Akto API requests and improve error message formatting in health check
This commit is contained in:
parent
5d5b530d8d
commit
119873bc2b
3 changed files with 27 additions and 10 deletions
|
|
@ -181,6 +181,7 @@ class AktoLogger(CustomLogger):
|
|||
"content-type": "application/json",
|
||||
"Authorization": self.akto_api_key,
|
||||
},
|
||||
"timeout": 10,
|
||||
}
|
||||
|
||||
async def async_health_check(self) -> dict:
|
||||
|
|
|
|||
|
|
@ -349,7 +349,10 @@ async def health_services_endpoint( # noqa: PLR0915
|
|||
response = await akto_logger.async_health_check()
|
||||
except Exception as e:
|
||||
verbose_proxy_logger.warning("Akto health check error: %s", e)
|
||||
return {"status": "unhealthy", "error_message": "Akto health check failed"}
|
||||
return {
|
||||
"status": "unhealthy",
|
||||
"error_message": "Akto health check failed",
|
||||
}
|
||||
return {
|
||||
"status": response["status"],
|
||||
"message": (
|
||||
|
|
|
|||
|
|
@ -255,15 +255,25 @@ async def test_async_log_failure_with_status_code(logger, sample_kwargs):
|
|||
|
||||
|
||||
def test_extract_client_ip_forwarded():
|
||||
assert AktoLogger.extract_client_ip(
|
||||
{"proxy_server_request": {"headers": {"x-forwarded-for": "1.2.3.4, 5.6.7.8"}}}
|
||||
) == "1.2.3.4"
|
||||
assert (
|
||||
AktoLogger.extract_client_ip(
|
||||
{
|
||||
"proxy_server_request": {
|
||||
"headers": {"x-forwarded-for": "1.2.3.4, 5.6.7.8"}
|
||||
}
|
||||
}
|
||||
)
|
||||
== "1.2.3.4"
|
||||
)
|
||||
|
||||
|
||||
def test_extract_client_ip_real_ip():
|
||||
assert AktoLogger.extract_client_ip(
|
||||
{"proxy_server_request": {"headers": {"x-real-ip": "10.0.0.1"}}}
|
||||
) == "10.0.0.1"
|
||||
assert (
|
||||
AktoLogger.extract_client_ip(
|
||||
{"proxy_server_request": {"headers": {"x-real-ip": "10.0.0.1"}}}
|
||||
)
|
||||
== "10.0.0.1"
|
||||
)
|
||||
|
||||
|
||||
def test_extract_client_ip_fallback():
|
||||
|
|
@ -274,9 +284,12 @@ def test_extract_client_ip_fallback():
|
|||
|
||||
|
||||
def test_extract_request_path_from_metadata():
|
||||
assert AktoLogger.extract_request_path(
|
||||
{"metadata": {"user_api_key_request_route": "/v1/embeddings"}}
|
||||
) == "/v1/embeddings"
|
||||
assert (
|
||||
AktoLogger.extract_request_path(
|
||||
{"metadata": {"user_api_key_request_route": "/v1/embeddings"}}
|
||||
)
|
||||
== "/v1/embeddings"
|
||||
)
|
||||
|
||||
|
||||
def test_extract_request_path_fallback():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue