From ae04a990b0393b4f837053c025426babdb34e7b9 Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Thu, 9 May 2024 20:07:20 +0200 Subject: [PATCH] feat: customizable request id field key --- middleware.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/middleware.go b/middleware.go index eab9827..5ba9cc7 100644 --- a/middleware.go +++ b/middleware.go @@ -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 @@ -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