From 9851ac3437acf0f145bce88ee1406539262f75bc Mon Sep 17 00:00:00 2001 From: Mikayla Toffler Date: Wed, 22 Jan 2025 09:49:27 -0500 Subject: [PATCH] 128bit logging for logrus --- contrib/sirupsen/logrus/logrus.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/sirupsen/logrus/logrus.go b/contrib/sirupsen/logrus/logrus.go index d0e379d796..2d58deca5d 100644 --- a/contrib/sirupsen/logrus/logrus.go +++ b/contrib/sirupsen/logrus/logrus.go @@ -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" @@ -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 }