From c10f51e16d323330d39e7e63628d893e91e003cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 02:58:43 +0000 Subject: [PATCH 1/4] build(deps): bump codecov/codecov-action from 3.1.4 to 4.1.1 (#804) * build(deps): bump codecov/codecov-action from 3.1.4 to 4.1.1 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.4 to 4.1.1. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/eaaf4bedf32dbdc6b720b63067d99c4d77d6047d...c16abc29c95fcf9174b58eb7e1abf4c866893bc8) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Update test.yml --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Michi Hoffmann --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 598d4ef1b..2aef61b5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,9 +50,10 @@ jobs: - name: Test run: make test-coverage - name: Upload coverage to Codecov - uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@v3.1.4 + uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # pin@v4.1.1 with: directory: .coverage + token: ${{ secrets.CODECOV_TOKEN }} - name: Test (with race detection) run: make test-race # The race detector adds considerable runtime overhead. To save time on From 271dc4912721dd895cef0d595a24c6e844b4cf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emir=20Ribi=C4=87?= Date: Tue, 2 Apr 2024 09:43:22 +0200 Subject: [PATCH 2/4] use set for sensitiveHeaders (#802) Co-authored-by: Michi Hoffmann --- interfaces.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/interfaces.go b/interfaces.go index d57f753a8..c11994a50 100644 --- a/interfaces.go +++ b/interfaces.go @@ -37,15 +37,6 @@ const ( LevelFatal Level = "fatal" ) -func getSensitiveHeaders() map[string]bool { - return map[string]bool{ - "Authorization": true, - "Cookie": true, - "X-Forwarded-For": true, - "X-Real-Ip": true, - } -} - // SdkInfo contains all metadata about about the SDK being used. type SdkInfo struct { Name string `json:"name,omitempty"` @@ -171,6 +162,13 @@ type Request struct { Env map[string]string `json:"env,omitempty"` } +var sensitiveHeaders = map[string]struct{}{ + "Authorization": {}, + "Cookie": {}, + "X-Forwarded-For": {}, + "X-Real-Ip": {}, +} + // NewRequest returns a new Sentry Request from the given http.Request. // // NewRequest avoids operations that depend on network access. In particular, it @@ -201,7 +199,6 @@ func NewRequest(r *http.Request) *Request { env = map[string]string{"REMOTE_ADDR": addr, "REMOTE_PORT": port} } } else { - sensitiveHeaders := getSensitiveHeaders() for k, v := range r.Header { if _, ok := sensitiveHeaders[k]; !ok { headers[k] = strings.Join(v, ",") From f9c3e8b36b6f4ebdba965816f55f2358cb658dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emir=20Ribi=C4=87?= Date: Tue, 2 Apr 2024 09:44:26 +0200 Subject: [PATCH 3/4] minor improvements (#803) Co-authored-by: Michi Hoffmann --- dsn.go | 3 +-- interfaces.go | 3 +-- internal/ratelimit/category.go | 17 ++++++++--------- sentry.go | 19 +++++++++---------- traces_profiler.go | 6 +++--- tracing.go | 4 ++-- 6 files changed, 24 insertions(+), 28 deletions(-) diff --git a/dsn.go b/dsn.go index 52d9b9f7c..ac6991a4f 100644 --- a/dsn.go +++ b/dsn.go @@ -90,11 +90,10 @@ func NewDsn(rawURL string) (*Dsn, error) { // Port var port int if parsedURL.Port() != "" { - parsedPort, err := strconv.Atoi(parsedURL.Port()) + port, err = strconv.Atoi(parsedURL.Port()) if err != nil { return nil, &DsnParseError{"invalid port"} } - port = parsedPort } else { port = scheme.defaultPort() } diff --git a/interfaces.go b/interfaces.go index c11994a50..a9b2f0222 100644 --- a/interfaces.go +++ b/interfaces.go @@ -523,13 +523,12 @@ func (e *Event) checkInMarshalJSON() ([]byte, error) { // NewEvent creates a new Event. func NewEvent() *Event { - event := Event{ + return &Event{ Contexts: make(map[string]Context), Extra: make(map[string]interface{}), Tags: make(map[string]string), Modules: make(map[string]string), } - return &event } // Thread specifies threads that were running at the time of an event. diff --git a/internal/ratelimit/category.go b/internal/ratelimit/category.go index cf5dff50b..2db76d2bf 100644 --- a/internal/ratelimit/category.go +++ b/internal/ratelimit/category.go @@ -32,15 +32,14 @@ var knownCategories = map[Category]struct{}{ // String returns the category formatted for debugging. func (c Category) String() string { - switch c { - case "": + if c == "" { return "CategoryAll" - default: - caser := cases.Title(language.English) - rv := "Category" - for _, w := range strings.Fields(string(c)) { - rv += caser.String(w) - } - return rv } + + caser := cases.Title(language.English) + rv := "Category" + for _, w := range strings.Fields(string(c)) { + rv += caser.String(w) + } + return rv } diff --git a/sentry.go b/sentry.go index 3df2cdbcb..c0acb4375 100644 --- a/sentry.go +++ b/sentry.go @@ -72,18 +72,17 @@ func Recover() *EventID { // RecoverWithContext captures a panic and passes relevant context object. func RecoverWithContext(ctx context.Context) *EventID { - if err := recover(); err != nil { - var hub *Hub - - if HasHubOnContext(ctx) { - hub = GetHubFromContext(ctx) - } else { - hub = CurrentHub() - } + err := recover() + if err == nil { + return nil + } - return hub.RecoverWithContext(ctx, err) + hub := GetHubFromContext(ctx) + if hub == nil { + hub = CurrentHub() } - return nil + + return hub.RecoverWithContext(ctx, err) } // WithScope is a shorthand for CurrentHub().WithScope. diff --git a/traces_profiler.go b/traces_profiler.go index 2655fe848..d56743193 100644 --- a/traces_profiler.go +++ b/traces_profiler.go @@ -7,8 +7,8 @@ import ( // Checks whether the transaction should be profiled (according to ProfilesSampleRate) // and starts a profiler if so. -func (span *Span) sampleTransactionProfile() { - var sampleRate = span.clientOptions().ProfilesSampleRate +func (s *Span) sampleTransactionProfile() { + var sampleRate = s.clientOptions().ProfilesSampleRate switch { case sampleRate < 0.0 || sampleRate > 1.0: Logger.Printf("Skipping transaction profiling: ProfilesSampleRate out of range [0.0, 1.0]: %f\n", sampleRate) @@ -19,7 +19,7 @@ func (span *Span) sampleTransactionProfile() { if globalProfiler == nil { Logger.Println("Skipping transaction profiling: the profiler couldn't be started") } else { - span.collectProfile = collectTransactionProfile + s.collectProfile = collectTransactionProfile } } } diff --git a/tracing.go b/tracing.go index 0dce16250..1bb53d0de 100644 --- a/tracing.go +++ b/tracing.go @@ -169,11 +169,11 @@ func StartSpan(ctx context.Context, operation string, options ...SpanOption) *Sp span.Sampled = span.sample() + span.recorder = &spanRecorder{} if hasParent { span.recorder = parent.spanRecorder() - } else { - span.recorder = &spanRecorder{} } + span.recorder.record(&span) hub := hubFromContext(ctx) From c12c44b787b5180ca8ca8bf5ee3777737bb0e926 Mon Sep 17 00:00:00 2001 From: Michi Hoffmann Date: Tue, 2 Apr 2024 09:45:55 +0200 Subject: [PATCH 4/4] Revert "ci: add the common Danger workflow (#799)" (#805) This reverts commit 3c523e27bbeee6226debe3e9662574a460954cd9 --- .craft.yml | 2 +- .github/workflows/danger.yml | 9 --------- CHANGELOG.md | 11 ----------- 3 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 .github/workflows/danger.yml diff --git a/.craft.yml b/.craft.yml index 55aff0f4b..238288e45 100644 --- a/.craft.yml +++ b/.craft.yml @@ -1,5 +1,5 @@ minVersion: 0.35.0 -changelogPolicy: auto +changelogPolicy: simple artifactProvider: name: none targets: diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml deleted file mode 100644 index 000b75ff3..000000000 --- a/.github/workflows/danger.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: Danger - -on: - pull_request: - types: [opened, synchronize, reopened, edited, ready_for_review] - -jobs: - danger: - uses: getsentry/github-workflows/.github/workflows/danger.yml@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 45d27a4e6..4d2670722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,5 @@ # Changelog -## Unreleased - -### Features - -- Accept `interface{}` for span data values ([#784](https://github.com/getsentry/sentry-go/pull/784)) -- Automatic transactions for Echo integration ([#722](https://github.com/getsentry/sentry-go/pull/722)) -- Add `http.request.method` attribute for performance span data ([#786](https://github.com/getsentry/sentry-go/pull/786)) -- Automatic transactions for Fasthttp integration ([#732](https://github.com/getsentry/sentry-go/pull/723)) -- Add `Fiber` integration ([#795](https://github.com/getsentry/sentry-go/pull/795)) -- Use `errors.Unwrap()` to create exception groups ([#792](https://github.com/getsentry/sentry-go/pull/792)) - ## 0.27.0 The Sentry SDK team is happy to announce the immediate availability of Sentry Go SDK v0.27.0.