From 949321a8fcb3c4c402ef15a885f4e101359ec037 Mon Sep 17 00:00:00 2001 From: Jonas Hungershausen Date: Mon, 27 May 2024 16:04:11 +0200 Subject: [PATCH] chore: cr --- logrusx/helper.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/logrusx/helper.go b/logrusx/helper.go index 48382369..b612413d 100644 --- a/logrusx/helper.go +++ b/logrusx/helper.go @@ -95,7 +95,7 @@ func (l *Logger) WithRequest(r *http.Request) *Logger { _, _, spanCtx = otelhttptrace.Extract(r.Context(), r, opts) } if spanCtx.IsValid() { - traces := map[string]string{} + traces := make(map[string]string, 2) if spanCtx.HasTraceID() { traces["trace_id"] = spanCtx.TraceID().String() } @@ -107,16 +107,13 @@ func (l *Logger) WithRequest(r *http.Request) *Logger { return ll } -func (l *Logger) WithSpan(sc trace.Span) *Logger { - if sc == nil { - return l - } - spanCtx := sc.SpanContext() +func (l *Logger) WithSpanFromContext(ctx context.Context) *Logger { + spanCtx := trace.SpanContextFromContext(ctx) if !spanCtx.IsValid() { return l } - traces := map[string]string{} + traces := make(map[string]string, 2) if spanCtx.HasTraceID() { traces["trace_id"] = spanCtx.TraceID().String() }