diff --git a/go.mod b/go.mod index 1bac27c0..3445aec5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/alphagov/router go 1.21 require ( - github.com/getsentry/sentry-go v0.25.0 + github.com/getsentry/sentry-go v0.26.0 github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 github.com/onsi/ginkgo/v2 v2.13.2 github.com/onsi/gomega v1.30.0 diff --git a/go.sum b/go.sum index a3c484a3..91db1a95 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-gk v0.0.0-20200319235926-a69029f61654 h1:XOPLOMn/zT4jIgxfxSsoXPxkrzz0FaCHwp33x5POJ+Q= github.com/dgryski/go-gk v0.0.0-20200319235926-a69029f61654/go.mod h1:qm+vckxRlDt0aOla0RYJJVeqHZlWfOm2UIxHaqPB46E= -github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX1eOyI= -github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= +github.com/getsentry/sentry-go v0.26.0 h1:IX3++sF6/4B5JcevhdZfdKIHfyvMmAq/UnqcyT2H6mA= +github.com/getsentry/sentry-go v0.26.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= 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/.golangci.yml b/vendor/github.com/getsentry/sentry-go/.golangci.yml index 0f353238..285e5870 100644 --- a/vendor/github.com/getsentry/sentry-go/.golangci.yml +++ b/vendor/github.com/getsentry/sentry-go/.golangci.yml @@ -2,8 +2,6 @@ linters: disable-all: true enable: - bodyclose - - deadcode - - depguard - dogsled - dupl - errcheck @@ -24,12 +22,10 @@ linters: - prealloc - revive - staticcheck - - structcheck - typecheck - unconvert - unparam - unused - - varcheck - whitespace issues: exclude-rules: diff --git a/vendor/github.com/getsentry/sentry-go/CHANGELOG.md b/vendor/github.com/getsentry/sentry-go/CHANGELOG.md index ca8f199d..303945b0 100644 --- a/vendor/github.com/getsentry/sentry-go/CHANGELOG.md +++ b/vendor/github.com/getsentry/sentry-go/CHANGELOG.md @@ -1,10 +1,37 @@ # Changelog +## 0.26.0 + +The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.26.0. + +### Breaking Changes + +As previously announced, this release removes some methods from the SDK. + +- `sentry.TransactionName()` use `sentry.WithTransactionName()` instead. +- `sentry.OpName()` use `sentry.WithOpName()` instead. +- `sentry.TransctionSource()` use `sentry.WithTransactionSource()` instead. +- `sentry.SpanSampled()` use `sentry.WithSpanSampled()` instead. + +### Features + +- Add `WithDescription` span option ([#751](https://github.com/getsentry/sentry-go/pull/751)) + + ```go + span := sentry.StartSpan(ctx, "http.client", WithDescription("GET /api/users")) + ``` +- Add support for package name parsing in Go 1.20 and higher ([#730](https://github.com/getsentry/sentry-go/pull/730)) + +### Bug Fixes + +- Apply `ClientOptions.SampleRate` only to errors & messages ([#754](https://github.com/getsentry/sentry-go/pull/754)) +- Check if git is available before executing any git commands ([#737](https://github.com/getsentry/sentry-go/pull/737)) + ## 0.25.0 The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.25.0. -### Deprecations +### Breaking Changes As previously announced, this release removes two global constants from the SDK. diff --git a/vendor/github.com/getsentry/sentry-go/client.go b/vendor/github.com/getsentry/sentry-go/client.go index 0e14658a..f5069b71 100644 --- a/vendor/github.com/getsentry/sentry-go/client.go +++ b/vendor/github.com/getsentry/sentry-go/client.go @@ -605,9 +605,9 @@ func (client *Client) processEvent(event *Event, hint *EventHint, scope EventMod } // Transactions are sampled by options.TracesSampleRate or - // options.TracesSampler when they are started. All other events - // (errors, messages) are sampled here. - if event.Type != transactionType && !sample(client.options.SampleRate) { + // options.TracesSampler when they are started. Other events + // (errors, messages) are sampled here. Does not apply to check-ins. + if event.Type != transactionType && event.Type != checkInType && !sample(client.options.SampleRate) { Logger.Println("Event dropped due to SampleRate hit.") return nil } @@ -626,7 +626,7 @@ func (client *Client) processEvent(event *Event, hint *EventHint, scope EventMod Logger.Println("Transaction dropped due to BeforeSendTransaction callback.") return nil } - } else if event.Type != transactionType && client.options.BeforeSend != nil { + } else if event.Type != transactionType && event.Type != checkInType && client.options.BeforeSend != nil { // All other events if event = client.options.BeforeSend(event, hint); event == nil { Logger.Println("Event dropped due to BeforeSend callback.") diff --git a/vendor/github.com/getsentry/sentry-go/integrations.go b/vendor/github.com/getsentry/sentry-go/integrations.go index 046ef0a0..4d76bef6 100644 --- a/vendor/github.com/getsentry/sentry-go/integrations.go +++ b/vendor/github.com/getsentry/sentry-go/integrations.go @@ -27,7 +27,7 @@ func (mi *modulesIntegration) SetupOnce(client *Client) { client.AddEventProcessor(mi.processor) } -func (mi *modulesIntegration) processor(event *Event, hint *EventHint) *Event { +func (mi *modulesIntegration) processor(event *Event, _ *EventHint) *Event { if len(event.Modules) == 0 { mi.once.Do(func() { info, ok := debug.ReadBuildInfo() @@ -70,7 +70,7 @@ func (ei *environmentIntegration) SetupOnce(client *Client) { client.AddEventProcessor(ei.processor) } -func (ei *environmentIntegration) processor(event *Event, hint *EventHint) *Event { +func (ei *environmentIntegration) processor(event *Event, _ *EventHint) *Event { // Initialize maps as necessary. contextNames := []string{"device", "os", "runtime"} if event.Contexts == nil { @@ -135,7 +135,7 @@ func (iei *ignoreErrorsIntegration) SetupOnce(client *Client) { client.AddEventProcessor(iei.processor) } -func (iei *ignoreErrorsIntegration) processor(event *Event, hint *EventHint) *Event { +func (iei *ignoreErrorsIntegration) processor(event *Event, _ *EventHint) *Event { suspects := getIgnoreErrorsSuspects(event) for _, suspect := range suspects { @@ -195,7 +195,7 @@ func (iei *ignoreTransactionsIntegration) SetupOnce(client *Client) { client.AddEventProcessor(iei.processor) } -func (iei *ignoreTransactionsIntegration) processor(event *Event, hint *EventHint) *Event { +func (iei *ignoreTransactionsIntegration) processor(event *Event, _ *EventHint) *Event { suspect := event.Transaction if suspect == "" { return event @@ -233,7 +233,7 @@ func (cfi *contextifyFramesIntegration) SetupOnce(client *Client) { client.AddEventProcessor(cfi.processor) } -func (cfi *contextifyFramesIntegration) processor(event *Event, hint *EventHint) *Event { +func (cfi *contextifyFramesIntegration) processor(event *Event, _ *EventHint) *Event { // Range over all exceptions for _, ex := range event.Exception { // If it has no stacktrace, just bail out @@ -353,7 +353,7 @@ func (ti *globalTagsIntegration) SetupOnce(client *Client) { client.AddEventProcessor(ti.processor) } -func (ti *globalTagsIntegration) processor(event *Event, hint *EventHint) *Event { +func (ti *globalTagsIntegration) processor(event *Event, _ *EventHint) *Event { if len(ti.tags) == 0 && len(ti.envTags) == 0 { return event } diff --git a/vendor/github.com/getsentry/sentry-go/interfaces.go b/vendor/github.com/getsentry/sentry-go/interfaces.go index 49779288..13517f64 100644 --- a/vendor/github.com/getsentry/sentry-go/interfaces.go +++ b/vendor/github.com/getsentry/sentry-go/interfaces.go @@ -11,15 +11,14 @@ import ( "time" ) -// Protocol Docs (kinda) -// https://github.com/getsentry/rust-sentry-types/blob/master/src/protocol/v7.rs +// eventType is the type of an error event. +const eventType = "event" // transactionType is the type of a transaction event. const transactionType = "transaction" -// eventType is the type of an error event. -const eventType = "event" - +// profileType is the type of a profile event. +// currently, profiles are always sent as part of a transaction event. const profileType = "profile" // checkInType is the type of a check in event. diff --git a/vendor/github.com/getsentry/sentry-go/sentry.go b/vendor/github.com/getsentry/sentry-go/sentry.go index 3f8fef15..c44f9069 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.25.0" +const SDKVersion = "0.26.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 4c288ab7..2f8933ea 100644 --- a/vendor/github.com/getsentry/sentry-go/stacktrace.go +++ b/vendor/github.com/getsentry/sentry-go/stacktrace.go @@ -355,9 +355,7 @@ func callerFunctionName() string { // It replicates https://golang.org/pkg/debug/gosym/#Sym.PackageName, avoiding a // dependency on debug/gosym. func packageName(name string) string { - // 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.") { + if isCompilerGeneratedSymbol(name) { return "" } 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 new file mode 100644 index 00000000..f6fb8e1e --- /dev/null +++ b/vendor/github.com/getsentry/sentry-go/stacktrace_below_go1.20.go @@ -0,0 +1,15 @@ +//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_go1.20.go b/vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go new file mode 100644 index 00000000..ff1cbf60 --- /dev/null +++ b/vendor/github.com/getsentry/sentry-go/stacktrace_go1.20.go @@ -0,0 +1,15 @@ +//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/tracing.go b/vendor/github.com/getsentry/sentry-go/tracing.go index dc968d67..4d51c0d5 100644 --- a/vendor/github.com/getsentry/sentry-go/tracing.go +++ b/vendor/github.com/getsentry/sentry-go/tracing.go @@ -49,11 +49,6 @@ type Span struct { //nolint: maligned // prefer readability over optimal memory // parent refers to the immediate local parent span. A remote parent span is // only referenced by setting ParentSpanID. parent *Span - // isTransaction is true only for the root span of a local span tree. The - // root span is the first span started in a context. Note that a local root - // span may have a remote parent belonging to the same trace, therefore - // isTransaction depends on ctx and not on parent. - isTransaction bool // recorder stores all spans in a transaction. Guaranteed to be non-nil. recorder *spanRecorder // span context, can only be set on transactions @@ -114,9 +109,8 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp StartTime: time.Now(), Sampled: SampledUndefined, - ctx: context.WithValue(ctx, spanContextKey{}, &span), - parent: parent, - isTransaction: !hasParent, + ctx: context.WithValue(ctx, spanContextKey{}, &span), + parent: parent, } if hasParent { @@ -257,7 +251,7 @@ func (s *Span) SetContext(key string, value Context) { // IsTransaction checks if the given span is a transaction. func (s *Span) IsTransaction() bool { - return s.isTransaction + return s.parent == nil } // GetTransaction returns the transaction that contains this span. @@ -289,7 +283,7 @@ func (s *Span) GetTransaction() *Span { // func (s *Span) TransactionName() string // func (s *Span) SetTransactionName(name string) -// ToSentryTrace returns the seralized TraceParentContext from a transaction/sapn. +// ToSentryTrace returns the seralized TraceParentContext from a transaction/span. // Use this function to propagate the TraceParentContext to a downstream SDK, // either as the value of the "sentry-trace" HTTP header, or as an html "sentry-trace" meta tag. func (s *Span) ToSentryTrace() string { @@ -326,7 +320,7 @@ func (s *Span) ToBaggage() string { // SetDynamicSamplingContext sets the given dynamic sampling context on the // current transaction. func (s *Span) SetDynamicSamplingContext(dsc DynamicSamplingContext) { - if s.isTransaction { + if s.IsTransaction() { s.dynamicSamplingContext = dsc } } @@ -391,7 +385,7 @@ func (s *Span) updateFromSentryTrace(header []byte) (updated bool) { } func (s *Span) updateFromBaggage(header []byte) { - if s.isTransaction { + if s.IsTransaction() { dsc, err := DynamicSamplingContextFromHeader(header) if err != nil { return @@ -452,7 +446,7 @@ func (s *Span) sample() Sampled { // Note: non-transaction should always have a parent, but we check both // conditions anyway -- the first for semantic meaning, the second to // avoid a nil pointer dereference. - if !s.isTransaction && s.parent != nil { + if !s.IsTransaction() && s.parent != nil { return s.parent.Sampled } @@ -516,7 +510,7 @@ func (s *Span) toEvent() *Event { s.mu.Lock() defer s.mu.Unlock() - if !s.isTransaction { + if !s.IsTransaction() { return nil // only transactions can be transformed into events } @@ -829,17 +823,6 @@ func (s Sampled) Bool() bool { // A SpanOption is a function that can modify the properties of a span. type SpanOption func(s *Span) -// The TransactionName option sets the name of the current transaction. -// -// A span tree has a single transaction name, therefore using this option when -// starting a span affects the span tree as a whole, potentially overwriting a -// name set previously. -// -// Deprecated: To be removed in 0.26.0. Use WithTransactionName() instead. -func TransactionName(name string) SpanOption { - return WithTransactionName(name) -} - // WithTransactionName option sets the name of the current transaction. // // A span tree has a single transaction name, therefore using this option when @@ -851,11 +834,11 @@ func WithTransactionName(name string) SpanOption { } } -// OpName sets the operation name for a given span. -// -// Deprecated: To be removed in 0.26.0. Use WithOpName() instead. -func OpName(name string) SpanOption { - return WithOpName(name) +// WithDescription sets the description of a span. +func WithDescription(description string) SpanOption { + return func(s *Span) { + s.Description = description + } } // WithOpName sets the operation name for a given span. @@ -865,13 +848,6 @@ func WithOpName(name string) SpanOption { } } -// TransctionSource sets the source of the transaction name. -// -// Deprecated: To be removed in 0.26.0. Use WithTransactionSource() instead. -func TransctionSource(source TransactionSource) SpanOption { - return WithTransactionSource(source) -} - // WithTransactionSource sets the source of the transaction name. // // Note: if the transaction source is not a valid source (as described @@ -883,13 +859,6 @@ func WithTransactionSource(source TransactionSource) SpanOption { } } -// SpanSampled updates the sampling flag for a given span. -// -// Deprecated: To be removed in 0.26.0. Use WithSpanSampled() instead. -func SpanSampled(sampled Sampled) SpanOption { - return WithSpanSampled(sampled) -} - // WithSpanSampled updates the sampling flag for a given span. func WithSpanSampled(sampled Sampled) SpanOption { return func(s *Span) { diff --git a/vendor/github.com/getsentry/sentry-go/util.go b/vendor/github.com/getsentry/sentry-go/util.go index 47f81485..2d2ee4ca 100644 --- a/vendor/github.com/getsentry/sentry-go/util.go +++ b/vendor/github.com/getsentry/sentry-go/util.go @@ -78,24 +78,28 @@ func defaultRelease() (release string) { // v1.0.1-0-g9de4 // v2.0-8-g77df-dirty // 4f72d7 - cmd := exec.Command("git", "describe", "--long", "--always", "--dirty") - b, err := cmd.Output() - if err != nil { - // Either Git is not available or the current directory is not a - // Git repository. - var s strings.Builder - fmt.Fprintf(&s, "Release detection failed: %v", err) - if err, ok := err.(*exec.ExitError); ok && len(err.Stderr) > 0 { - fmt.Fprintf(&s, ": %s", err.Stderr) + if _, err := exec.LookPath("git"); err == nil { + cmd := exec.Command("git", "describe", "--long", "--always", "--dirty") + b, err := cmd.Output() + if err != nil { + // Either Git is not available or the current directory is not a + // Git repository. + var s strings.Builder + fmt.Fprintf(&s, "Release detection failed: %v", err) + if err, ok := err.(*exec.ExitError); ok && len(err.Stderr) > 0 { + fmt.Fprintf(&s, ": %s", err.Stderr) + } + Logger.Print(s.String()) + } else { + release = strings.TrimSpace(string(b)) + Logger.Printf("Using release from Git: %s", release) + return release } - Logger.Print(s.String()) - Logger.Print("Some Sentry features will not be available. See https://docs.sentry.io/product/releases/.") - Logger.Print("To stop seeing this message, pass a Release to sentry.Init or set the SENTRY_RELEASE environment variable.") - return "" } - release = strings.TrimSpace(string(b)) - Logger.Printf("Using release from Git: %s", release) - return release + + Logger.Print("Some Sentry features will not be available. See https://docs.sentry.io/product/releases/.") + Logger.Print("To stop seeing this message, pass a Release to sentry.Init or set the SENTRY_RELEASE environment variable.") + return "" } func revisionFromBuildInfo(info *debug.BuildInfo) string { diff --git a/vendor/modules.txt b/vendor/modules.txt index dbd51bf6..f292fd3a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,7 +7,7 @@ github.com/cespare/xxhash/v2 # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/getsentry/sentry-go v0.25.0 +# github.com/getsentry/sentry-go v0.26.0 ## explicit; go 1.18 github.com/getsentry/sentry-go github.com/getsentry/sentry-go/internal/debug