Skip to content

Commit

Permalink
Don’t export sdkMetaData
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Nov 7, 2022
1 parent df61c9f commit 7ecd814
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 22 deletions.
47 changes: 29 additions & 18 deletions client_test.go
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions fasthttp/sentryfasthttp_test.go
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions http/sentryhttp_test.go
Expand Up @@ -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{},
Expand Down
4 changes: 2 additions & 2 deletions interfaces.go
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tracing.go
Expand Up @@ -359,7 +359,7 @@ func (s *Span) toEvent() *Event {
Timestamp: s.EndTime,
StartTime: s.StartTime,
Spans: finished,
SDKMetaData: SDKMetaData{
sdkMetaData: SDKMetaData{
DynamicSamplingContextKey: s.dynamicSamplingContext,
},
}
Expand Down
3 changes: 3 additions & 0 deletions tracing_test.go
Expand Up @@ -152,6 +152,7 @@ func TestStartSpan(t *testing.T) {
cmpopts.IgnoreFields(Event{},
"Contexts", "EventID", "Level", "Platform",
"Release", "Sdk", "ServerName", "Modules",
"sdkMetaData",
),
cmpopts.EquateEmpty(),
}
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -285,6 +287,7 @@ func TestStartTransaction(t *testing.T) {
cmpopts.IgnoreFields(Event{},
"Contexts", "EventID", "Level", "Platform",
"Release", "Sdk", "ServerName", "Modules",
"sdkMetaData",
),
cmpopts.EquateEmpty(),
}
Expand Down
2 changes: 1 addition & 1 deletion transport.go
Expand Up @@ -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 {
Expand Down

0 comments on commit 7ecd814

Please sign in to comment.