feat: 性能监控基础设施、解密缓存及计费简化

- 新增 PerfRecorder 性能记录工具,支持采样率与慢请求日志
- 在请求管道中埋点:auth、body_read、json_parse、context_build、authorize、handle
- 流处理器增加 parse/conversion 耗时追踪与 perf_metrics 落库
- 解密服务添加 LRU 缓存,降低高频解密 CPU 开销
- 格式转换分层开关设计:全局 OFF 时回退到端点配置,而非一刀切拒绝
- 移除 shadow billing 模块,统一使用新计费引擎
- 新增 Codex 网关请求适配器(store=false、role 映射、include 补齐)
- endpoint 创建接口支持 body_rules 参数
This commit is contained in:
fawney19
2026-02-05 14:22:11 +08:00
parent e72e5370c4
commit ed2ff5c1d7
25 changed files with 836 additions and 963 deletions

View File

@@ -78,10 +78,18 @@ def is_format_compatible(
if provider_key == client_key:
return True, False, None
# 2. 格式不同 -> 需要检查格式转换开关
# 如果总开关为 False直接拒绝禁用任何跨格式转换
if not effective_conversion_enabled:
return False, False, "格式转换已禁用enable_format_conversion=false"
# 2. 格式不同 -> 需要检查格式转换开关(分层开关)
#
# 设计语义(与模块顶部注释一致):
# - 全局开关 ON -> 强制允许跨格式(通常 caller 会传 skip_endpoint_check=True
# - 全局开关 OFF -> 不再“一刀切”拒绝,而是回退到 provider/endpoint 开关:
# - provider 开关 ON -> 强制允许skip_endpoint_check=True跳过端点检查
# - provider 开关 OFF -> 由端点 format_acceptance_config 决定skip_endpoint_check=False
#
# 说明:
# - effective_conversion_enabled 表示“全局默认允许”,不是“全局总闸/kill switch”
# - 当它为 False 时我们仍然会继续执行后续检查provider/endpoint
# 兼容“按 Provider/Endpoint 精细化开启转换”的场景。
# 3. 如果全局或提供商开关为 ON跳过端点配置检查
if not skip_endpoint_check: