Skip to content

Commit

Permalink
feat: customizable request id field key
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed May 9, 2024
1 parent 346cd93 commit 854bfce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ const (
)

var (
TraceIDKey = "trace-id"
SpanIDKey = "span-id"
TraceIDKey = "trace-id"
SpanIDKey = "span-id"
RequestIDKey = "id"

RequestBodyMaxSize = 64 * 1024 // 64KB
ResponseBodyMaxSize = 64 * 1024 // 64KB
Expand Down Expand Up @@ -174,7 +175,7 @@ func NewWithConfig(logger *slog.Logger, config Config) echo.MiddlewareFunc {
requestID = res.Header().Get(echo.HeaderXRequestID)
}
if requestID != "" {
baseAttributes = append(baseAttributes, slog.String("id", requestID))
baseAttributes = append(baseAttributes, slog.String(RequestIDKey, requestID))
}
}

Expand Down

0 comments on commit 854bfce

Please sign in to comment.