Skip to content

feat: migrate from raven-go to sentry-go#13

Merged
ankurs merged 2 commits intomainfrom
feat/migrate-sentry-go
Mar 24, 2026
Merged

feat: migrate from raven-go to sentry-go#13
ankurs merged 2 commits intomainfrom
feat/migrate-sentry-go

Conversation

@ankurs
Copy link
Member

@ankurs ankurs commented Mar 24, 2026

Summary

  • Replace deprecated github.com/getsentry/raven-go with modern github.com/getsentry/sentry-go SDK
  • All changes contained in notifier/ package — no public API changes
  • Add buildSentryEvent helper to deduplicate event construction between doNotify and NotifyOnPanic
  • Add sentry.Flush to Close() for graceful shutdown
  • Add comprehensive test suite for Sentry integration (notifier_sentry_test.go)

Test plan

  • make build passes
  • make test passes (including 9 new Sentry tests)
  • make lint passes with 0 issues
  • go.mod no longer references raven-go or certifi/gocertifi
  • Full monorepo make build and make test pass (all 9 packages)
  • Verify Sentry event delivery in staging environment with real DSN

Summary by CodeRabbit

  • Chores

    • Upgraded error reporting integration to a newer Sentry implementation and refreshed dependency set for improved stability.
  • Documentation

    • Updated notifier documentation links and clarified Close behavior to flush pending Sentry events with a 2-second timeout.
  • Tests

    • Added comprehensive tests for the Sentry notifier covering initialization, event conversion, level mapping, tags/extras, panic capture, and shutdown.

Replace the deprecated, unmaintained github.com/getsentry/raven-go SDK
with the modern github.com/getsentry/sentry-go SDK. All changes are
contained within the notifier package.

Key changes:
- InitSentry now uses sentry.Init with ClientOptions
- Stack frame conversion builds sentry.Frame structs directly with
  proper Module/Function splitting for Sentry UI grouping
- Event building extracted into buildSentryEvent helper, used by both
  doNotify and NotifyOnPanic
- Environment/Release stored in package vars and stamped per-event so
  post-init calls to SetEnvironment/SetRelease take effect immediately
- Close() now flushes sentry events with a 2s timeout

No breaking changes to the public API.
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

Migrates Sentry integration from raven-go to sentry-go: updates go.mod dependencies, refactors notifier implementation to use the new Sentry SDK (event construction, level mapping, stacktrace conversion, flush on close), updates README anchors, and adds end-to-end tests for the Sentry notifier.

Changes

Cohort / File(s) Summary
Dependency Updates
go.mod
Replaced github.com/getsentry/raven-go v0.2.0 with github.com/getsentry/sentry-go v0.43.0; removed some indirect deps and added golang.org/x/text v0.33.0 as indirect.
Documentation
notifier/README.md
Updated README anchor links to match new notifier.go line anchors and changed Close description to mention flushing pending Sentry events with a 2s timeout.
Sentry Integration
notifier/notifier.go
Refactored Sentry usage to sentry-go: replaced DSN/init calls, added sentryEnvironment/sentryRelease, added buildSentryEvent, changed capture to sentry.CaptureEvent, converted stacktraces/frames to sentry.Stacktrace/[]sentry.Frame, and call sentry.Flush on Close.
Tests
notifier/notifier_sentry_test.go
Added tests exercising Sentry init, level mapping, stacktrace conversion, tag/env/release propagation, Notify/NotifyOnPanic behavior, and Close behavior using a synchronous transport and BeforeSend capture hook.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰
Hop-hop, the raven took to flight,
Sentry hops in, all crisp and bright.
Frames aligned and levels true,
New deps, new tests — a clean revue!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: migrate from raven-go to sentry-go' directly and accurately describes the main objective of the changeset: replacing the deprecated raven-go Sentry client library with the newer sentry-go library.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/migrate-sentry-go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the notifier/ package from the deprecated github.com/getsentry/raven-go client to github.com/getsentry/sentry-go, updating Sentry initialization, event construction, shutdown flushing, and adding a dedicated Sentry test suite.

Changes:

  • Replace Raven usage with Sentry-Go initialization and event capture, including a shared buildSentryEvent helper.
  • Update shutdown behavior to flush Sentry events in Close().
  • Add Sentry-focused tests validating stacktrace conversion, level mapping, tags/extras, env/release, and panic reporting.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
notifier/notifier.go Migrates runtime stack conversion + event building/capture to sentry-go, and flushes on close.
notifier/notifier_sentry_test.go Adds a test harness capturing events via BeforeSend and validates Sentry event fields.
notifier/README.md Updates generated function anchor links/line references to match moved code.
go.mod Swaps raven-go dependency for sentry-go and updates indirect requirements.
go.sum Removes Raven/certifi sums and adds Sentry-Go (and transitive) sums.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
notifier/notifier.go (1)

184-191: Consider conditional InApp based on module path.

All frames are marked InApp: true, which tells Sentry to consider all frames as application code for grouping and display. This may cause noise from third-party library frames. Consider checking if the module path starts with your project's module prefix to set InApp appropriately.

♻️ Suggested refinement
+// modulePrefix could be set via SetServerRoot or derived from go.mod
+var modulePrefix = "github.com/go-coldbrew/"
+
 frames = append(frames, sentry.Frame{
     Function: function,
     Module:   module,
     Filename: fr.File,
     AbsPath:  fr.File,
     Lineno:   fr.Line,
-    InApp:    true,
+    InApp:    strings.HasPrefix(module, modulePrefix),
 })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@notifier/notifier.go` around lines 184 - 191, Update the sentry.Frame
construction so InApp is set conditionally based on the module path instead of
always true: when appending frames in the block that builds sentry.Frame (the
frames = append(...) call), compute InApp by checking whether the module string
starts with your project module prefix (e.g., using strings.HasPrefix(module,
projectModulePrefix)) or similar heuristic and set sentry.Frame.InApp
accordingly; ensure you reference the module variable and the sentry.Frame
creation so third‑party frames are marked InApp=false while your code remains
InApp=true.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@notifier/notifier.go`:
- Around line 184-191: Update the sentry.Frame construction so InApp is set
conditionally based on the module path instead of always true: when appending
frames in the block that builds sentry.Frame (the frames = append(...) call),
compute InApp by checking whether the module string starts with your project
module prefix (e.g., using strings.HasPrefix(module, projectModulePrefix)) or
similar heuristic and set sentry.Frame.InApp accordingly; ensure you reference
the module variable and the sentry.Frame creation so third‑party frames are
marked InApp=false while your code remains InApp=true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82262337-4a19-4239-946a-b242abd40b62

📥 Commits

Reviewing files that changed from the base of the PR and between e26a85e and bdbfc94.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • go.mod
  • notifier/README.md
  • notifier/notifier.go
  • notifier/notifier_sentry_test.go

- Update Close() doc comment to mention Sentry flush and 2s timeout
- Avoid unnecessary map allocation in buildSentryEvent when tagData is
  empty
- Use t.Cleanup in initTestSentry to reset globals automatically,
  removing manual defers from each test
- Add t.Cleanup to TestInitSentry_ValidDSN for consistent state reset
@ankurs ankurs requested a review from Copilot March 24, 2026 09:16
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
notifier/notifier.go (1)

462-463: Minor: Hyphenate compound adjective.

"2 second timeout" should be "2-second timeout" per standard grammar rules for compound adjectives. This is the source for the auto-generated README.

Proposed fix
 // Close closes the airbrake notifier and flushes pending Sentry events.
-// Sentry events are flushed with a 2 second timeout.
+// Sentry events are flushed with a 2-second timeout.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@notifier/notifier.go` around lines 462 - 463, Update the comment for the
Close function to hyphenate the compound adjective: change the phrase "2 second
timeout" to "2-second timeout" in the doc comment above the Close method in
notifier.go so the generated README uses the correct grammar.
notifier/README.md (1)

48-48: Minor grammar issue originates in source code.

The phrase "2 second timeout" should be hyphenated as "2-second timeout" (compound adjective). Since this README is auto-generated from source comments, the fix should be applied to the doc comment in notifier/notifier.go around line 463.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@notifier/README.md` at line 48, Update the doc comment for the Close method
in notifier/notifier.go (the comment that documents Close around line 463) to
hyphenate the compound adjective by changing "2 second timeout" to "2-second
timeout" so the generated README reads correctly; edit the comment text above
the Close function declaration accordingly and regenerate docs if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@notifier/notifier.go`:
- Around line 462-463: Update the comment for the Close function to hyphenate
the compound adjective: change the phrase "2 second timeout" to "2-second
timeout" in the doc comment above the Close method in notifier.go so the
generated README uses the correct grammar.

In `@notifier/README.md`:
- Line 48: Update the doc comment for the Close method in notifier/notifier.go
(the comment that documents Close around line 463) to hyphenate the compound
adjective by changing "2 second timeout" to "2-second timeout" so the generated
README reads correctly; edit the comment text above the Close function
declaration accordingly and regenerate docs if needed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d8c63747-b4f3-4ebd-a921-82232cd6fcc3

📥 Commits

Reviewing files that changed from the base of the PR and between bdbfc94 and 66983a8.

📒 Files selected for processing (3)
  • notifier/README.md
  • notifier/notifier.go
  • notifier/notifier_sentry_test.go
✅ Files skipped from review due to trivial changes (1)
  • notifier/notifier_sentry_test.go

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ankurs ankurs merged commit 2711f19 into main Mar 24, 2026
12 checks passed
@ankurs ankurs deleted the feat/migrate-sentry-go branch March 24, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants