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 03c1ea4 commit ae04a99
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 @@ -18,8 +18,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 @@ -165,7 +166,7 @@ func NewWithConfig(logger *slog.Logger, config Config) gin.HandlerFunc {
}

if config.WithRequestID {
baseAttributes = append(baseAttributes, slog.String("id", requestID))
baseAttributes = append(baseAttributes, slog.String(RequestIDKey, requestID))
}

// otel
Expand Down

0 comments on commit ae04a99

Please # to comment.