feat: 建立可观测性、容量与恢复验证基线

This commit is contained in:
weijuesen
2026-08-14 14:54:56 +08:00
parent 126c215a6b
commit 1e6a5dbfb8
16 changed files with 398 additions and 3 deletions
+10
View File
@@ -2,6 +2,7 @@ package middleware
import (
"log/slog"
"strings"
"time"
"github.com/gin-gonic/gin"
@@ -17,13 +18,22 @@ func Logger() gin.HandlerFunc {
latency := time.Since(start)
status := c.Writer.Status()
query := RedactSensitiveQuery(c.Request.URL.RawQuery)
auth := c.GetHeader("Authorization")
authPrefix := ""
if auth != "" {
authPrefix = strings.SplitN(auth, " ", 2)[0]
}
slog.Info("请求",
"requestId", RequestID(c),
"method", c.Request.Method,
"path", path,
"query", query,
"status", status,
"latency", latency.String(),
"ip", c.ClientIP(),
"authType", authPrefix,
)
}
}