Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transaction.data to contexts.trace.data #864

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,6 @@ func (s *Span) toEvent() *Event {
Transaction: s.Name,
Contexts: contexts,
Tags: s.Tags,
Extra: s.Data,
Timestamp: s.EndTime,
StartTime: s.StartTime,
Spans: finished,
Expand All @@ -588,6 +587,7 @@ func (s *Span) traceContext() *TraceContext {
SpanID: s.SpanID,
ParentSpanID: s.ParentSpanID,
Op: s.Op,
Data: s.Data,
Description: s.Description,
Status: s.Status,
}
Expand Down Expand Up @@ -763,12 +763,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) {
Expand Down Expand Up @@ -811,6 +812,10 @@ func (tc TraceContext) Map() map[string]interface{} {
m["status"] = tc.Status
}

if len(tc.Data) > 0 {
m["data"] = tc.Data
}

return m
}

Expand Down
14 changes: 4 additions & 10 deletions tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,12 @@ func TestStartSpan(t *testing.T) {
SpanID: span.SpanID,
ParentSpanID: parentSpanID,
Op: op,
Data: span.Data,
Description: description,
Status: status,
}.Map(),
},
Tags: nil,
// TODO(tracing): the root span / transaction data field is
// mapped into Event.Extra for now, pending spec clarification.
// https://github.com/getsentry/develop/issues/244#issuecomment-778694182
Extra: span.Data,
Tags: nil,
Timestamp: endTime,
StartTime: startTime,
TransactionInfo: &TransactionInfo{
Expand Down Expand Up @@ -283,16 +280,13 @@ func TestStartTransaction(t *testing.T) {
"trace": TraceContext{
TraceID: transaction.TraceID,
SpanID: transaction.SpanID,
Data: transaction.Data,
Description: description,
Status: status,
}.Map(),
"otel": {"k": "v"},
},
Tags: nil,
// TODO(tracing): the root span / transaction data field is
// mapped into Event.Extra for now, pending spec clarification.
// https://github.com/getsentry/develop/issues/244#issuecomment-778694182
Extra: transaction.Data,
Tags: nil,
Timestamp: endTime,
StartTime: startTime,
TransactionInfo: &TransactionInfo{
Expand Down
Loading