feat: 系统设置新增原始请求/响应记录开关(仅管理员)
- 系统配置键 log_raw_requests:开启后,仅管理员账号的每次请求 在用量明细中保存客户端原始请求体与上游原始响应体 (流式含全部 SSE 事件),用于排障 - UsageLog 新增 raw_request / raw_response 字段(type:text) - AuthLLM 附带 user_role 供网关判断管理员 - gateway:10s TTL 缓存开关;streamResponse/bufferResponse 支持累积上游原始响应;recordUsage 填充原始字段 - 前端 SystemConfig 新增开关(会显著增加存储的提示) - 新增 doc/flow.md 网关调用流程示意图
This commit is contained in:
@@ -32,6 +32,8 @@ type Event struct {
|
||||
CacheReadPrice float64
|
||||
TraceID string // TraceID for distributed tracing
|
||||
ModelID uint64 // Model ID from channel-model binding
|
||||
RawRequest string // 客户端原始请求体(仅管理员+开关开启时记录)
|
||||
RawResponse string // 上游原始响应(未转换;流式为全部 SSE 事件)
|
||||
}
|
||||
|
||||
// Recorder handles async usage recording
|
||||
@@ -153,6 +155,8 @@ func (r *Recorder) flush(events []Event) {
|
||||
ErrorCode: errCode,
|
||||
RequestID: e.RequestID,
|
||||
TraceID: e.TraceID,
|
||||
RawRequest: e.RawRequest,
|
||||
RawResponse: e.RawResponse,
|
||||
}
|
||||
logs = append(logs, log)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user