Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased Changes

### Breaking Cahnges
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Breaking Cahnges
### 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.
Expand Down
9 changes: 8 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions echo/sentryecho_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions gin/sentrygin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading