From c8628d6957855af44fb3946ac82a27c62b26fd91 Mon Sep 17 00:00:00 2001 From: Samuel Berthe Date: Sat, 17 Aug 2024 20:51:50 +0200 Subject: [PATCH] fix: replace trace-id by trace_id spec: https://opentelemetry.io/docs/specs/otel/compatibility/logging_trace_context --- README.md | 4 ++-- middleware.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d0666e5..d11aaf7 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,8 @@ Attributes will be injected in log payload. Other global parameters: ```go -slogecho.TraceIDKey = "trace-id" -slogecho.SpanIDKey = "span-id" +slogecho.TraceIDKey = "trace_id" +slogecho.SpanIDKey = "span_id" slogecho.RequestBodyMaxSize = 64 * 1024 // 64KB slogecho.ResponseBodyMaxSize = 64 * 1024 // 64KB slogecho.HiddenRequestHeaders = map[string]struct{}{ ... } diff --git a/middleware.go b/middleware.go index bbcc1f7..4ef58e3 100644 --- a/middleware.go +++ b/middleware.go @@ -18,8 +18,8 @@ const ( ) var ( - TraceIDKey = "trace-id" - SpanIDKey = "span-id" + TraceIDKey = "trace_id" + SpanIDKey = "span_id" RequestIDKey = "id" RequestBodyMaxSize = 64 * 1024 // 64KB @@ -308,6 +308,7 @@ func NewWithConfig(logger *slog.Logger, config Config) echo.MiddlewareFunc { } } +// AddCustomAttributes adds custom attributes to the request context. func AddCustomAttributes(c echo.Context, attr slog.Attr) { v := c.Get(customAttributesCtxKey) if v == nil {