Skip to content

Commit

Permalink
fix: Send root span data as Event.Extra (#329)
Browse files Browse the repository at this point in the history
* fix: Send root span data as Event.Extra

Pending spec clarification since implementation in Relay and different
SDKs diverged.

For now sending data in Event.Extra gets the information into the
Transaction view in Sentry.

* docs: move comment to test

The test explains the intent and desired behavior. If the desired
behavior changes, we need to update the test and are thus more likely to
update/remove the comment.
  • Loading branch information
rhcarvalho authored Feb 17, 2021
1 parent 981a202 commit fb7df73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ func (s *Span) toEvent() *Event {
"trace": s.traceContext(),
},
Tags: s.Tags,
Extra: s.Data,
Timestamp: s.EndTime,
StartTime: s.StartTime,
Spans: finished,
Expand Down
11 changes: 8 additions & 3 deletions tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ func TestStartSpan(t *testing.T) {
sampled := SampledTrue
startTime := time.Now()
endTime := startTime.Add(3 * time.Second)
data := map[string]interface{}{
"k": "v",
}
span := StartSpan(ctx, op,
TransactionName(transaction),
func(s *Span) {
Expand All @@ -108,6 +111,7 @@ func TestStartSpan(t *testing.T) {
s.Sampled = sampled
s.StartTime = startTime
s.EndTime = endTime
s.Data = data
},
)
span.Finish()
Expand Down Expand Up @@ -135,9 +139,10 @@ func TestStartSpan(t *testing.T) {
},
},
Tags: nil,
// TODO(tracing): Set Transaction.Data here or in
// Contexts.Trace, or somewhere else. Currently ignored.
Extra: 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,
Timestamp: endTime,
StartTime: startTime,
}
Expand Down

0 comments on commit fb7df73

Please sign in to comment.