diff --git a/CHANGELOG.md b/CHANGELOG.md index d8beaa05f..c8a7dfd57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased Changes + +### Breaking Changes + +- Behavioral change for the `TraceIgnoreStatusCodes` option. The option now defaults to ignoring 404 status codes. + ## 0.36.2 The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.36.2. diff --git a/client.go b/client.go index 346230223..03800f81a 100644 --- a/client.go +++ b/client.go @@ -247,7 +247,10 @@ type ClientOptions struct { // [][]int{{404}, {500}} // ignore status codes 404 and 500 // [][]int{{404}, {400, 405}, {500, 599}} // ignore 404, range 400-405, and range 500-599 // - // By default, this is empty and all status codes are traced. + // By default, this ignores 404 status codes. + // + // IMPORTANT: to not ignore any status codes, the option should be an empty slice and not nil. The nil option is + // used for defaulting to 404 ignores. TraceIgnoreStatusCodes [][]int } @@ -325,6 +328,10 @@ func NewClient(options ClientOptions) (*Client, error) { options.MaxSpans = defaultMaxSpans } + if options.TraceIgnoreStatusCodes == nil { + options.TraceIgnoreStatusCodes = [][]int{{404}} + } + // SENTRYGODEBUG is a comma-separated list of key=value pairs (similar // to GODEBUG). It is not a supported feature: recognized debug options // may change any time. diff --git a/client_test.go b/client_test.go index de9d43418..9f0eea7ba 100644 --- a/client_test.go +++ b/client_test.go @@ -733,7 +733,12 @@ func TestTraceIgnoreStatusCodes(t *testing.T) { statusCode interface{} expectDrop bool }{ - "No ignored codes": { + "Default behavior: ignoreStatusCodes = nil, should drop 404s": { + statusCode: 404, + ignoreStatusCodes: nil, + expectDrop: true, + }, + "Specify No ignored codes": { statusCode: 404, ignoreStatusCodes: [][]int{}, expectDrop: false, diff --git a/echo/sentryecho_test.go b/echo/sentryecho_test.go index 03a060589..74f17022e 100644 --- a/echo/sentryecho_test.go +++ b/echo/sentryecho_test.go @@ -356,8 +356,9 @@ func TestIntegration(t *testing.T) { transactionsCh := make(chan *sentry.Event, len(tests)) err := sentry.Init(sentry.ClientOptions{ - EnableTracing: true, - TracesSampleRate: 1.0, + EnableTracing: true, + TracesSampleRate: 1.0, + TraceIgnoreStatusCodes: make([][]int, 0), // don't ignore any status codes BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { eventsCh <- event return event diff --git a/gin/sentrygin_test.go b/gin/sentrygin_test.go index 01dbdff33..51527872f 100644 --- a/gin/sentrygin_test.go +++ b/gin/sentrygin_test.go @@ -354,8 +354,9 @@ func TestIntegration(t *testing.T) { eventsCh := make(chan *sentry.Event, len(tests)) transactionsCh := make(chan *sentry.Event, len(tests)) err := sentry.Init(sentry.ClientOptions{ - EnableTracing: true, - TracesSampleRate: 1.0, + EnableTracing: true, + TracesSampleRate: 1.0, + TraceIgnoreStatusCodes: make([][]int, 0), // don't ignore any status codes BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event { eventsCh <- event return event