diff --git a/go.mod b/go.mod index 4946a585..99887565 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/alphagov/router go 1.22.5 require ( - github.com/getsentry/sentry-go v0.29.1 + github.com/getsentry/sentry-go v0.30.0 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 github.com/jackc/pgx/v5 v5.7.1 github.com/onsi/ginkgo/v2 v2.22.0 diff --git a/go.sum b/go.sum index d151d5f4..002fda38 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA= -github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0= +github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo= +github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= diff --git a/vendor/github.com/getsentry/sentry-go/.craft.yml b/vendor/github.com/getsentry/sentry-go/.craft.yml index 238288e4..25ecf685 100644 --- a/vendor/github.com/getsentry/sentry-go/.craft.yml +++ b/vendor/github.com/getsentry/sentry-go/.craft.yml @@ -8,6 +8,12 @@ targets: - name: github tagPrefix: otel/v tagOnly: true + - name: github + tagPrefix: slog/v + tagOnly: true + - name: github + tagPrefix: zerolog/v + tagOnly: true - name: registry sdks: github:getsentry/sentry-go: diff --git a/vendor/github.com/getsentry/sentry-go/CHANGELOG.md b/vendor/github.com/getsentry/sentry-go/CHANGELOG.md index 4818085c..533d1dd0 100644 --- a/vendor/github.com/getsentry/sentry-go/CHANGELOG.md +++ b/vendor/github.com/getsentry/sentry-go/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.30.0 + +The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.30.0. + +### Features + +- Add `sentryzerolog` integration ([#857](https://github.com/getsentry/sentry-go/pull/857)) +- Add `sentryslog` integration ([#865](https://github.com/getsentry/sentry-go/pull/865)) +- Always set Mechanism Type to generic ([#896](https://github.com/getsentry/sentry-go/pull/897)) + +### Bug Fixes + +- Prevent panic in `fasthttp` and `fiber` integration in case a malformed URL has to be parsed ([#912](https://github.com/getsentry/sentry-go/pull/912)) + +### Misc + +Drop support for Go 1.18, 1.19 and 1.20. The currently supported Go versions are the last 3 stable releases: 1.23, 1.22 and 1.21. + ## 0.29.1 The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.29.1. @@ -9,6 +27,10 @@ The Sentry SDK team is happy to announce the immediate availability of Sentry Go - Correlate errors to the current trace ([#886](https://github.com/getsentry/sentry-go/pull/886)) - Set the trace context when the transaction finishes ([#888](https://github.com/getsentry/sentry-go/pull/888)) +### Misc + +- Update the `sentrynegroni` integration to use the latest (v3.1.1) version of Negroni ([#885](https://github.com/getsentry/sentry-go/pull/885)) + ## 0.29.0 The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.29.0. diff --git a/vendor/github.com/getsentry/sentry-go/Makefile b/vendor/github.com/getsentry/sentry-go/Makefile index 89523ac0..9cc0959f 100644 --- a/vendor/github.com/getsentry/sentry-go/Makefile +++ b/vendor/github.com/getsentry/sentry-go/Makefile @@ -58,9 +58,8 @@ test-coverage: $(COVERAGE_REPORT_DIR) clean-report-dir ## Test with coverage en mod-tidy: ## Check go.mod tidiness set -e ; \ for dir in $(ALL_GO_MOD_DIRS); do \ - cd "$${dir}"; \ echo ">>> Running 'go mod tidy' for module: $${dir}"; \ - go mod tidy -go=1.18 -compat=1.18; \ + (cd "$${dir}" && go mod tidy -go=1.21 -compat=1.21); \ done; \ git diff --exit-code; .PHONY: mod-tidy @@ -68,12 +67,12 @@ mod-tidy: ## Check go.mod tidiness vet: ## Run "go vet" set -e ; \ for dir in $(ALL_GO_MOD_DIRS); do \ - cd "$${dir}"; \ echo ">>> Running 'go vet' for module: $${dir}"; \ - go vet ./...; \ + (cd "$${dir}" && go vet ./...); \ done; .PHONY: vet + lint: ## Lint (using "golangci-lint") golangci-lint run .PHONY: lint diff --git a/vendor/github.com/getsentry/sentry-go/README.md b/vendor/github.com/getsentry/sentry-go/README.md index 3b67fb45..bbd9c430 100644 --- a/vendor/github.com/getsentry/sentry-go/README.md +++ b/vendor/github.com/getsentry/sentry-go/README.md @@ -75,8 +75,10 @@ checkout the official documentation: - [net/http](https://docs.sentry.io/platforms/go/guides/http/) - [echo](https://docs.sentry.io/platforms/go/guides/echo/) - [fasthttp](https://docs.sentry.io/platforms/go/guides/fasthttp/) + - [fiber](https://docs.sentry.io/platforms/go/guides/fiber/) - [gin](https://docs.sentry.io/platforms/go/guides/gin/) - [iris](https://docs.sentry.io/platforms/go/guides/iris/) + - [logrus](https://docs.sentry.io/platforms/go/guides/logrus/) - [negroni](https://docs.sentry.io/platforms/go/guides/negroni/) ## Resources diff --git a/vendor/github.com/getsentry/sentry-go/client.go b/vendor/github.com/getsentry/sentry-go/client.go index b5b11b31..3b46be98 100644 --- a/vendor/github.com/getsentry/sentry-go/client.go +++ b/vendor/github.com/getsentry/sentry-go/client.go @@ -590,14 +590,6 @@ func (client *Client) GetSDKIdentifier() string { return client.sdkIdentifier } -// reverse reverses the slice a in place. -func reverse(a []Exception) { - for i := len(a)/2 - 1; i >= 0; i-- { - opp := len(a) - 1 - i - a[i], a[opp] = a[opp], a[i] - } -} - func (client *Client) processEvent(event *Event, hint *EventHint, scope EventModifier) *EventID { if event == nil { err := usageError{fmt.Errorf("%s called with nil event", callerFunctionName())} diff --git a/vendor/github.com/getsentry/sentry-go/dynamic_sampling_context.go b/vendor/github.com/getsentry/sentry-go/dynamic_sampling_context.go index 6eec95ba..8dae0838 100644 --- a/vendor/github.com/getsentry/sentry-go/dynamic_sampling_context.go +++ b/vendor/github.com/getsentry/sentry-go/dynamic_sampling_context.go @@ -100,15 +100,17 @@ func (d DynamicSamplingContext) String() string { } members = append(members, member) } - if len(members) > 0 { - baggage, err := baggage.New(members...) - if err != nil { - return "" - } - return baggage.String() + + if len(members) == 0 { + return "" + } + + baggage, err := baggage.New(members...) + if err != nil { + return "" } - return "" + return baggage.String() } // Constructs a new DynamicSamplingContext using a scope and client. Accessing diff --git a/vendor/github.com/getsentry/sentry-go/hub.go b/vendor/github.com/getsentry/sentry-go/hub.go index c99b6d70..04cebee3 100644 --- a/vendor/github.com/getsentry/sentry-go/hub.go +++ b/vendor/github.com/getsentry/sentry-go/hub.go @@ -294,8 +294,13 @@ func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) { } max := client.options.MaxBreadcrumbs - if max < 0 { + switch { + case max < 0: return + case max == 0: + max = defaultMaxBreadcrumbs + case max > maxBreadcrumbs: + max = maxBreadcrumbs } if client.options.BeforeBreadcrumb != nil { @@ -308,12 +313,6 @@ func (hub *Hub) AddBreadcrumb(breadcrumb *Breadcrumb, hint *BreadcrumbHint) { } } - if max == 0 { - max = defaultMaxBreadcrumbs - } else if max > maxBreadcrumbs { - max = maxBreadcrumbs - } - hub.Scope().AddBreadcrumb(breadcrumb, max) } diff --git a/vendor/github.com/getsentry/sentry-go/interfaces.go b/vendor/github.com/getsentry/sentry-go/interfaces.go index cacb2543..894a9a4d 100644 --- a/vendor/github.com/getsentry/sentry-go/interfaces.go +++ b/vendor/github.com/getsentry/sentry-go/interfaces.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "reflect" + "slices" "strings" "time" ) @@ -123,27 +124,27 @@ type User struct { } func (u User) IsEmpty() bool { - if len(u.ID) > 0 { + if u.ID != "" { return false } - if len(u.Email) > 0 { + if u.Email != "" { return false } - if len(u.IPAddress) > 0 { + if u.IPAddress != "" { return false } - if len(u.Username) > 0 { + if u.Username != "" { return false } - if len(u.Name) > 0 { + if u.Name != "" { return false } - if len(u.Segment) > 0 { + if u.Segment != "" { return false } @@ -238,8 +239,7 @@ type Mechanism struct { // SetUnhandled indicates that the exception is an unhandled exception, i.e. // from a panic. func (m *Mechanism) SetUnhandled() { - h := false - m.Handled = &h + m.Handled = Pointer(false) } // Exception specifies an error that occurred. @@ -398,12 +398,13 @@ func (e *Event) SetException(exception error, maxErrorDepth int) { } // event.Exception should be sorted such that the most recent error is last. - reverse(e.Exception) + slices.Reverse(e.Exception) for i := range e.Exception { e.Exception[i].Mechanism = &Mechanism{ IsExceptionGroup: true, ExceptionID: i, + Type: "generic", } if i == 0 { continue @@ -429,7 +430,9 @@ func (e *Event) MarshalJSON() ([]byte, error) { // and a few type tricks. if e.Type == transactionType { return e.transactionMarshalJSON() - } else if e.Type == checkInType { + } + + if e.Type == checkInType { return e.checkInMarshalJSON() } return e.defaultMarshalJSON() diff --git a/vendor/github.com/getsentry/sentry-go/metrics.go b/vendor/github.com/getsentry/sentry-go/metrics.go index bcc94e88..e6966bc3 100644 --- a/vendor/github.com/getsentry/sentry-go/metrics.go +++ b/vendor/github.com/getsentry/sentry-go/metrics.go @@ -5,7 +5,7 @@ import ( "hash/crc32" "math" "regexp" - "sort" + "slices" "strings" ) @@ -223,7 +223,7 @@ func (am abstractMetric) SerializeTags() string { for k := range am.tags { values = append(values, k) } - sortSlice(values) + slices.Sort(values) for _, key := range values { val := sanitizeValue(am.tags[key]) @@ -375,7 +375,7 @@ func (s SetMetric[T]) SerializeValue() string { for k := range s.values { values = append(values, k) } - sortSlice(values) + slices.Sort(values) var sb strings.Builder for _, el := range values { @@ -419,9 +419,3 @@ func sanitizeValue(s string) string { type Ordered interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 | ~string } - -func sortSlice[T Ordered](s []T) { - sort.Slice(s, func(i, j int) bool { - return s[i] < s[j] - }) -} diff --git a/vendor/github.com/getsentry/sentry-go/profiler.go b/vendor/github.com/getsentry/sentry-go/profiler.go index c0b858cc..c4f98dfe 100644 --- a/vendor/github.com/getsentry/sentry-go/profiler.go +++ b/vendor/github.com/getsentry/sentry-go/profiler.go @@ -2,6 +2,7 @@ package sentry import ( "container/ring" + "encoding/binary" "strconv" "runtime" @@ -377,13 +378,7 @@ func (p *profileRecorder) addStackTrace(capturedStack traceparser.Trace) int { p.stackKeyBuffer = append(p.stackKeyBuffer, 0) // space - // The following code is just like binary.AppendUvarint() which isn't yet available in Go 1.18. - x := uint64(frameIndex) + 1 - for x >= 0x80 { - p.stackKeyBuffer = append(p.stackKeyBuffer, byte(x)|0x80) - x >>= 7 - } - p.stackKeyBuffer = append(p.stackKeyBuffer, byte(x)) + p.stackKeyBuffer = binary.AppendUvarint(p.stackKeyBuffer, uint64(frameIndex)+1) } } diff --git a/vendor/github.com/getsentry/sentry-go/scope.go b/vendor/github.com/getsentry/sentry-go/scope.go index 5be1c02e..8245fdbd 100644 --- a/vendor/github.com/getsentry/sentry-go/scope.go +++ b/vendor/github.com/getsentry/sentry-go/scope.go @@ -478,7 +478,7 @@ func (scope *Scope) ApplyToEvent(event *Event, hint *EventHint, client *Client) // a proper deep copy: if some context values are pointer types (e.g. maps), // they won't be properly copied. func cloneContext(c Context) Context { - res := Context{} + res := make(Context, len(c)) for k, v := range c { res[k] = v } diff --git a/vendor/github.com/getsentry/sentry-go/sentry.go b/vendor/github.com/getsentry/sentry-go/sentry.go index 476eb178..49c17231 100644 --- a/vendor/github.com/getsentry/sentry-go/sentry.go +++ b/vendor/github.com/getsentry/sentry-go/sentry.go @@ -6,7 +6,7 @@ import ( ) // The version of the SDK. -const SDKVersion = "0.29.1" +const SDKVersion = "0.30.0" // apiVersion is the minimum version of the Sentry API compatible with the // sentry-go SDK. diff --git a/vendor/github.com/getsentry/sentry-go/stacktrace.go b/vendor/github.com/getsentry/sentry-go/stacktrace.go index 3b372bcf..f59e2366 100644 --- a/vendor/github.com/getsentry/sentry-go/stacktrace.go +++ b/vendor/github.com/getsentry/sentry-go/stacktrace.go @@ -4,6 +4,7 @@ import ( "go/build" "reflect" "runtime" + "slices" "strings" ) @@ -277,12 +278,7 @@ func extractFrames(pcs []uintptr) []runtime.Frame { } } - // TODO don't append and reverse, put in the right place from the start. - // reverse - for i, j := 0, len(frames)-1; i < j; i, j = i+1, j-1 { - frames[i], frames[j] = frames[j], frames[i] - } - + slices.Reverse(frames) return frames } @@ -336,12 +332,10 @@ func shouldSkipFrame(module string) bool { var goRoot = strings.ReplaceAll(build.Default.GOROOT, "\\", "/") func setInAppFrame(frame *Frame) { - if strings.HasPrefix(frame.AbsPath, goRoot) || - strings.Contains(frame.Module, "vendor") || + frame.InApp = true + if strings.HasPrefix(frame.AbsPath, goRoot) || strings.Contains(frame.Module, "vendor") || strings.Contains(frame.Module, "third_party") { frame.InApp = false - } else { - frame.InApp = true } } @@ -382,3 +376,32 @@ func baseName(name string) string { } return name } + +func isCompilerGeneratedSymbol(name string) bool { + // In versions of Go 1.20 and above a prefix of "type:" and "go:" is a + // compiler-generated symbol that doesn't belong to any package. + // See variable reservedimports in cmd/compile/internal/gc/subr.go + if strings.HasPrefix(name, "go:") || strings.HasPrefix(name, "type:") { + return true + } + return false +} + +// Walk backwards through the results and for the current function name +// remove it's parent function's prefix, leaving only it's actual name. This +// fixes issues grouping errors with the new fully qualified function names +// introduced from Go 1.21. +func cleanupFunctionNamePrefix(f []Frame) []Frame { + for i := len(f) - 1; i > 0; i-- { + name := f[i].Function + parentName := f[i-1].Function + "." + + if !strings.HasPrefix(name, parentName) { + continue + } + + f[i].Function = name[len(parentName):] + } + + return f +} diff --git a/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.20.go b/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.20.go deleted file mode 100644 index f6fb8e1e..00000000 --- a/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.20.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build !go1.20 - -package sentry - -import "strings" - -func isCompilerGeneratedSymbol(name string) bool { - // In versions of Go below 1.20 a prefix of "type." and "go." is a - // compiler-generated symbol that doesn't belong to any package. - // See variable reservedimports in cmd/compile/internal/gc/subr.go - if strings.HasPrefix(name, "go.") || strings.HasPrefix(name, "type.") { - return true - } - return false -} diff --git a/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.21.go b/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.21.go deleted file mode 100644 index 35a42e4d..00000000 --- a/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.21.go +++ /dev/null @@ -1,7 +0,0 @@ -//go:build !go1.21 - -package sentry - -func cleanupFunctionNamePrefix(f []Frame) []Frame { - return f -} diff --git a/vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go b/vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go deleted file mode 100644 index ff1cbf60..00000000 --- a/vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build go1.20 - -package sentry - -import "strings" - -func isCompilerGeneratedSymbol(name string) bool { - // In versions of Go 1.20 and above a prefix of "type:" and "go:" is a - // compiler-generated symbol that doesn't belong to any package. - // See variable reservedimports in cmd/compile/internal/gc/subr.go - if strings.HasPrefix(name, "go:") || strings.HasPrefix(name, "type:") { - return true - } - return false -} diff --git a/vendor/github.com/getsentry/sentry-go/stacktrace_go1.21.go b/vendor/github.com/getsentry/sentry-go/stacktrace_go1.21.go deleted file mode 100644 index 45147c85..00000000 --- a/vendor/github.com/getsentry/sentry-go/stacktrace_go1.21.go +++ /dev/null @@ -1,25 +0,0 @@ -//go:build go1.21 - -package sentry - -import "strings" - -// Walk backwards through the results and for the current function name -// remove it's parent function's prefix, leaving only it's actual name. This -// fixes issues grouping errors with the new fully qualified function names -// introduced from Go 1.21. - -func cleanupFunctionNamePrefix(f []Frame) []Frame { - for i := len(f) - 1; i > 0; i-- { - name := f[i].Function - parentName := f[i-1].Function + "." - - if !strings.HasPrefix(name, parentName) { - continue - } - - f[i].Function = name[len(parentName):] - } - - return f -} diff --git a/vendor/github.com/getsentry/sentry-go/tracing.go b/vendor/github.com/getsentry/sentry-go/tracing.go index b30ceb79..79a1bf3a 100644 --- a/vendor/github.com/getsentry/sentry-go/tracing.go +++ b/vendor/github.com/getsentry/sentry-go/tracing.go @@ -735,31 +735,32 @@ const ( maxSpanStatus ) +var spanStatuses = [maxSpanStatus]string{ + "", + "ok", + "cancelled", // [sic] + "unknown", + "invalid_argument", + "deadline_exceeded", + "not_found", + "already_exists", + "permission_denied", + "resource_exhausted", + "failed_precondition", + "aborted", + "out_of_range", + "unimplemented", + "internal_error", + "unavailable", + "data_loss", + "unauthenticated", +} + func (ss SpanStatus) String() string { if ss >= maxSpanStatus { return "" } - m := [maxSpanStatus]string{ - "", - "ok", - "cancelled", // [sic] - "unknown", - "invalid_argument", - "deadline_exceeded", - "not_found", - "already_exists", - "permission_denied", - "resource_exhausted", - "failed_precondition", - "aborted", - "out_of_range", - "unimplemented", - "internal_error", - "unavailable", - "data_loss", - "unauthenticated", - } - return m[ss] + return spanStatuses[ss] } func (ss SpanStatus) MarshalJSON() ([]byte, error) { diff --git a/vendor/github.com/getsentry/sentry-go/transport.go b/vendor/github.com/getsentry/sentry-go/transport.go index 02fc1d4f..25fe2d32 100644 --- a/vendor/github.com/getsentry/sentry-go/transport.go +++ b/vendor/github.com/getsentry/sentry-go/transport.go @@ -141,7 +141,7 @@ func encodeMetric(enc *json.Encoder, b io.Writer, metrics []Metric) error { return err } - return err + return nil } func encodeAttachment(enc *json.Encoder, b io.Writer, attachment *Attachment) error { @@ -279,10 +279,12 @@ func getRequestFromEvent(ctx context.Context, event *Event, dsn *Dsn) (r *http.R r.Header.Set("X-Sentry-Auth", auth) } }() + body := getRequestBodyFromEvent(event) if body == nil { return nil, errors.New("event could not be marshaled") } + envelope, err := envelopeFromBody(event, dsn, time.Now(), body) if err != nil { return nil, err diff --git a/vendor/modules.txt b/vendor/modules.txt index dbcd8fa9..68d5253c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -79,8 +79,8 @@ github.com/docker/go-units # github.com/felixge/httpsnoop v1.0.4 ## explicit; go 1.13 github.com/felixge/httpsnoop -# github.com/getsentry/sentry-go v0.29.1 -## explicit; go 1.18 +# github.com/getsentry/sentry-go v0.30.0 +## explicit; go 1.21 github.com/getsentry/sentry-go github.com/getsentry/sentry-go/internal/debug github.com/getsentry/sentry-go/internal/otel/baggage