Skip to content

Commit

Permalink
chore: cr
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed May 27, 2024
1 parent 920df43 commit 949321a
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions logrusx/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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()
}
Expand Down

0 comments on commit 949321a

Please sign in to comment.