Commit 962cd3da authored by Dave King's avatar Dave King Committed by 陈曦
Browse files

fix: add account and proxy details to gateway.forward_failed log



The forward_failed error log only included account_id, making it
difficult to identify which account and proxy caused the failure
without querying the database. Add account_name, account_platform,
and proxy details (id, name, host, port) to the log fields.
Co-Authored-By: default avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
parent c471951a
...@@ -422,11 +422,24 @@ func (h *GatewayHandler) Messages(c *gin.Context) { ...@@ -422,11 +422,24 @@ func (h *GatewayHandler) Messages(c *gin.Context) {
} }
} }
wroteFallback := h.ensureForwardErrorResponse(c, streamStarted) wroteFallback := h.ensureForwardErrorResponse(c, streamStarted)
reqLog.Error("gateway.forward_failed", forwardFailedFields := []zap.Field{
zap.Int64("account_id", account.ID), zap.Int64("account_id", account.ID),
zap.String("account_name", account.Name),
zap.String("account_platform", account.Platform),
zap.Bool("fallback_error_response_written", wroteFallback), zap.Bool("fallback_error_response_written", wroteFallback),
zap.Error(err), zap.Error(err),
) }
if account.Proxy != nil {
forwardFailedFields = append(forwardFailedFields,
zap.Int64("proxy_id", account.Proxy.ID),
zap.String("proxy_name", account.Proxy.Name),
zap.String("proxy_host", account.Proxy.Host),
zap.Int("proxy_port", account.Proxy.Port),
)
} else if account.ProxyID != nil {
forwardFailedFields = append(forwardFailedFields, zap.Int64p("proxy_id", account.ProxyID))
}
reqLog.Error("gateway.forward_failed", forwardFailedFields...)
return return
} }
...@@ -741,11 +754,24 @@ func (h *GatewayHandler) Messages(c *gin.Context) { ...@@ -741,11 +754,24 @@ func (h *GatewayHandler) Messages(c *gin.Context) {
} }
} }
wroteFallback := h.ensureForwardErrorResponse(c, streamStarted) wroteFallback := h.ensureForwardErrorResponse(c, streamStarted)
reqLog.Error("gateway.forward_failed", forwardFailedFields := []zap.Field{
zap.Int64("account_id", account.ID), zap.Int64("account_id", account.ID),
zap.String("account_name", account.Name),
zap.String("account_platform", account.Platform),
zap.Bool("fallback_error_response_written", wroteFallback), zap.Bool("fallback_error_response_written", wroteFallback),
zap.Error(err), zap.Error(err),
) }
if account.Proxy != nil {
forwardFailedFields = append(forwardFailedFields,
zap.Int64("proxy_id", account.Proxy.ID),
zap.String("proxy_name", account.Proxy.Name),
zap.String("proxy_host", account.Proxy.Host),
zap.Int("proxy_port", account.Proxy.Port),
)
} else if account.ProxyID != nil {
forwardFailedFields = append(forwardFailedFields, zap.Int64p("proxy_id", account.ProxyID))
}
reqLog.Error("gateway.forward_failed", forwardFailedFields...)
return return
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment