Skip to content

Commit

Permalink
128bit logging for logrus
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoffl01 committed Jan 22, 2025
1 parent b08de4b commit 9851ac3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion contrib/sirupsen/logrus/logrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package logrus

import (
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/ext"
"gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer"
"gopkg.in/DataDog/dd-trace-go.v1/internal/telemetry"
Expand Down Expand Up @@ -35,7 +36,12 @@ func (d *DDContextLogHook) Fire(e *logrus.Entry) error {
if !found {
return nil
}
e.Data[ext.LogKeyTraceID] = span.Context().TraceID()
spanCtx128, ok := span.Context().(ddtrace.SpanContextW3C)
if ok {
e.Data[ext.LogKeyTraceID] = spanCtx128.TraceID128()
} else {
e.Data[ext.LogKeyTraceID] = span.Context().TraceID()
}
e.Data[ext.LogKeySpanID] = span.Context().SpanID()
return nil
}

0 comments on commit 9851ac3

Please sign in to comment.