fix proxy pre call hook - only use if user is using alerting (#7683)

This commit is contained in:
Ishaan Jaff 2025-01-10 19:07:05 -08:00 committed by GitHub
parent 9ac18caf24
commit 2d1c90b688
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -473,10 +473,8 @@ class ProxyLogging:
3. /image/generation
"""
verbose_proxy_logger.debug("Inside Proxy Logging Pre-call hook!")
## ALERTING ###
asyncio.create_task(
self.slack_alerting_instance.response_taking_too_long(request_data=data)
)
self._init_response_taking_too_long_task(data=data)
if data is None:
return None
@ -1012,6 +1010,23 @@ class ProxyLogging:
raise e
return new_response
def _init_response_taking_too_long_task(self, data: Optional[dict] = None):
"""
Initialize the response taking too long task if user is using slack alerting
Only run task if user is using slack alerting
This handles checking for if a request is hanging for too long
"""
## ALERTING ###
if (
self.slack_alerting_instance
and self.slack_alerting_instance.alerting is not None
):
asyncio.create_task(
self.slack_alerting_instance.response_taking_too_long(request_data=data)
)
### DB CONNECTOR ###
# Define the retry decorator with backoff strategy