Skip to content

Commit ae04a99

Browse files
committed
feat: customizable request id field key
1 parent 03c1ea4 commit ae04a99

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

middleware.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ const (
1818
)
1919

2020
var (
21-
TraceIDKey = "trace-id"
22-
SpanIDKey = "span-id"
21+
TraceIDKey = "trace-id"
22+
SpanIDKey = "span-id"
23+
RequestIDKey = "id"
2324

2425
RequestBodyMaxSize = 64 * 1024 // 64KB
2526
ResponseBodyMaxSize = 64 * 1024 // 64KB
@@ -165,7 +166,7 @@ func NewWithConfig(logger *slog.Logger, config Config) gin.HandlerFunc {
165166
}
166167

167168
if config.WithRequestID {
168-
baseAttributes = append(baseAttributes, slog.String("id", requestID))
169+
baseAttributes = append(baseAttributes, slog.String(RequestIDKey, requestID))
169170
}
170171

171172
// otel

0 commit comments

Comments
 (0)