From 9eafd07ffc3c12dd8d3e31c28ce6d670138b87c8 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 26 Jul 2024 15:00:20 +0200 Subject: [PATCH] Add `transaction.data` to `contexts.trace.data` --- tracing.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tracing.go b/tracing.go index 9c5852872..b7710688d 100644 --- a/tracing.go +++ b/tracing.go @@ -760,12 +760,13 @@ func (ss SpanStatus) MarshalJSON() ([]byte, error) { // A TraceContext carries information about an ongoing trace and is meant to be // stored in Event.Contexts (as *TraceContext). type TraceContext struct { - TraceID TraceID `json:"trace_id"` - SpanID SpanID `json:"span_id"` - ParentSpanID SpanID `json:"parent_span_id"` - Op string `json:"op,omitempty"` - Description string `json:"description,omitempty"` - Status SpanStatus `json:"status,omitempty"` + TraceID TraceID `json:"trace_id"` + SpanID SpanID `json:"span_id"` + ParentSpanID SpanID `json:"parent_span_id"` + Op string `json:"op,omitempty"` + Description string `json:"description,omitempty"` + Status SpanStatus `json:"status,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` } func (tc *TraceContext) MarshalJSON() ([]byte, error) { @@ -808,6 +809,10 @@ func (tc TraceContext) Map() map[string]interface{} { m["status"] = tc.Status } + if len(tc.Data) > 0 { + m["data"] = tc.Data + } + return m }