mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-03 16:22:27 +08:00
feat(cache): enhance cache monitoring endpoints and handler integrations
This commit is contained in:
@@ -395,3 +395,24 @@ class BaseMessageHandler:
|
||||
|
||||
# 创建后台任务,不阻塞当前流
|
||||
asyncio.create_task(_do_update())
|
||||
|
||||
def _log_request_error(self, message: str, error: Exception) -> None:
|
||||
"""记录请求错误日志,对业务异常不打印堆栈
|
||||
|
||||
Args:
|
||||
message: 错误消息前缀
|
||||
error: 异常对象
|
||||
"""
|
||||
from src.core.exceptions import (
|
||||
ProviderException,
|
||||
QuotaExceededException,
|
||||
RateLimitException,
|
||||
ModelNotSupportedException,
|
||||
)
|
||||
|
||||
if isinstance(error, (ProviderException, QuotaExceededException, RateLimitException, ModelNotSupportedException)):
|
||||
# 业务异常:简洁日志,不打印堆栈
|
||||
logger.error(f"{message}: [{type(error).__name__}] {error}")
|
||||
else:
|
||||
# 未知异常:完整堆栈
|
||||
logger.exception(f"{message}: {error}")
|
||||
|
||||
@@ -382,7 +382,7 @@ class ChatHandlerBase(BaseMessageHandler, ABC):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.exception(f"流式请求失败: {e}")
|
||||
self._log_request_error("流式请求失败", e)
|
||||
await self._record_stream_failure(ctx, e, original_headers, original_request_body)
|
||||
raise
|
||||
|
||||
|
||||
@@ -413,20 +413,7 @@ class CliMessageHandlerBase(BaseMessageHandler):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
# 对于已知的业务异常,只记录简洁的错误信息,不输出完整堆栈
|
||||
from src.core.exceptions import (
|
||||
ProviderException,
|
||||
QuotaExceededException,
|
||||
RateLimitException,
|
||||
ModelNotSupportedException,
|
||||
)
|
||||
|
||||
if isinstance(e, (ProviderException, QuotaExceededException, RateLimitException, ModelNotSupportedException)):
|
||||
# 业务异常:简洁日志
|
||||
logger.error(f"流式请求失败: [{type(e).__name__}] {e}")
|
||||
else:
|
||||
# 未知异常:完整堆栈
|
||||
logger.exception(f"流式请求失败: {e}")
|
||||
self._log_request_error("流式请求失败", e)
|
||||
await self._record_stream_failure(ctx, e, original_headers, original_request_body)
|
||||
raise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user