diff --git a/client_test.go b/client_test.go index eb64d3db..d7d54d3a 100644 --- a/client_test.go +++ b/client_test.go @@ -78,11 +78,15 @@ func TestCaptureMessageEmptyString(t *testing.T) { }, } got := transport.lastEvent - opts := cmp.Transformer("SimplifiedEvent", func(e *Event) *Event { - return &Event{ - Exception: e.Exception, - } - }) + opts := cmp.Options{ + cmpopts.IgnoreFields(Event{}, "sdkMetaData"), + cmp.Transformer("SimplifiedEvent", func(e *Event) *Event { + return &Event{ + Exception: e.Exception, + } + }), + } + if diff := cmp.Diff(want, got, opts); diff != "" { t.Errorf("(-want +got):\n%s", diff) } @@ -282,7 +286,7 @@ func TestCaptureEvent(t *testing.T) { }, } got := transport.lastEvent - opts := cmp.Options{cmpopts.IgnoreFields(Event{}, "Release")} + opts := cmp.Options{cmpopts.IgnoreFields(Event{}, "Release", "sdkMetaData")} if diff := cmp.Diff(want, got, opts); diff != "" { t.Errorf("Event mismatch (-want +got):\n%s", diff) } @@ -309,11 +313,14 @@ func TestCaptureEventNil(t *testing.T) { }, } got := transport.lastEvent - opts := cmp.Transformer("SimplifiedEvent", func(e *Event) *Event { - return &Event{ - Exception: e.Exception, - } - }) + opts := cmp.Options{ + cmpopts.IgnoreFields(Event{}, "sdkMetaData"), + cmp.Transformer("SimplifiedEvent", func(e *Event) *Event { + return &Event{ + Exception: e.Exception, + } + }), + } if diff := cmp.Diff(want, got, opts); diff != "" { t.Errorf("(-want +got):\n%s", diff) } @@ -476,13 +483,17 @@ func TestRecover(t *testing.T) { t.Fatalf("events = %s\ngot %d events, want 1", b, len(events)) } got := events[0] - opts := cmp.Transformer("SimplifiedEvent", func(e *Event) *Event { - return &Event{ - Message: e.Message, - Exception: e.Exception, - Level: e.Level, - } - }) + opts := cmp.Options{ + cmpopts.IgnoreFields(Event{}, "sdkMetaData"), + cmp.Transformer("SimplifiedEvent", func(e *Event) *Event { + return &Event{ + Message: e.Message, + Exception: e.Exception, + Level: e.Level, + } + }), + } + if diff := cmp.Diff(want, got, opts); diff != "" { t.Errorf("(-want +got):\n%s", diff) } diff --git a/fasthttp/sentryfasthttp_test.go b/fasthttp/sentryfasthttp_test.go index 0c718636..3ee8b666 100644 --- a/fasthttp/sentryfasthttp_test.go +++ b/fasthttp/sentryfasthttp_test.go @@ -208,6 +208,7 @@ func TestIntegration(t *testing.T) { sentry.Event{}, "Contexts", "EventID", "Extra", "Platform", "Modules", "Release", "Sdk", "ServerName", "Tags", "Timestamp", + "sdkMetaData", ), cmpopts.IgnoreMapEntries(func(k string, v string) bool { // fasthttp changed Content-Length behavior in diff --git a/http/sentryhttp_test.go b/http/sentryhttp_test.go index 9b8efb54..2d97ce8b 100644 --- a/http/sentryhttp_test.go +++ b/http/sentryhttp_test.go @@ -216,6 +216,7 @@ func TestIntegration(t *testing.T) { sentry.Event{}, "Contexts", "EventID", "Extra", "Platform", "Modules", "Release", "Sdk", "ServerName", "Tags", "Timestamp", + "sdkMetaData", ), cmpopts.IgnoreFields( sentry.Request{}, diff --git a/interfaces.go b/interfaces.go index 9658e702..341f8aa7 100644 --- a/interfaces.go +++ b/interfaces.go @@ -221,7 +221,7 @@ const ( DynamicSamplingContextKey SDKMetaDataKey = "DynamicSamplingContext" ) -// SDKMetaData is a struct to stash data which is needed at some point in the SDK's event processing pipeline +// sdkMetaData is a struct to stash data which is needed at some point in the SDK's event processing pipeline // but which shouldn't get send to Sentry. type SDKMetaData struct { DynamicSamplingContextKey DynamicSamplingContext @@ -266,7 +266,7 @@ type Event struct { // The fields below are not part of the final JSON payload. - SDKMetaData SDKMetaData `json:"-"` + sdkMetaData SDKMetaData } // TODO: Event.Contexts map[string]interface{} => map[string]EventContext, diff --git a/tracing.go b/tracing.go index b5a4e199..f8231660 100644 --- a/tracing.go +++ b/tracing.go @@ -359,7 +359,7 @@ func (s *Span) toEvent() *Event { Timestamp: s.EndTime, StartTime: s.StartTime, Spans: finished, - SDKMetaData: SDKMetaData{ + sdkMetaData: SDKMetaData{ DynamicSamplingContextKey: s.dynamicSamplingContext, }, } diff --git a/tracing_test.go b/tracing_test.go index 347a6dde..e012b763 100644 --- a/tracing_test.go +++ b/tracing_test.go @@ -152,6 +152,7 @@ func TestStartSpan(t *testing.T) { cmpopts.IgnoreFields(Event{}, "Contexts", "EventID", "Level", "Platform", "Release", "Sdk", "ServerName", "Modules", + "sdkMetaData", ), cmpopts.EquateEmpty(), } @@ -211,6 +212,7 @@ func TestStartChild(t *testing.T) { cmpopts.IgnoreFields(Event{}, "EventID", "Level", "Platform", "Modules", "Release", "Sdk", "ServerName", "Timestamp", "StartTime", + "sdkMetaData", ), cmpopts.IgnoreMapEntries(func(k string, v interface{}) bool { return k != "trace" @@ -285,6 +287,7 @@ func TestStartTransaction(t *testing.T) { cmpopts.IgnoreFields(Event{}, "Contexts", "EventID", "Level", "Platform", "Release", "Sdk", "ServerName", "Modules", + "sdkMetaData", ), cmpopts.EquateEmpty(), } diff --git a/transport.go b/transport.go index f9168d1c..05bcd3c7 100644 --- a/transport.go +++ b/transport.go @@ -98,7 +98,7 @@ func transactionEnvelopeFromBody(event *Event, dsn *Dsn, sentAt time.Time, body var b bytes.Buffer enc := json.NewEncoder(&b) - dsc := event.SDKMetaData.DynamicSamplingContextKey + dsc := event.sdkMetaData.DynamicSamplingContextKey var trace = map[string]string{} for k, v := range dsc.Entries {