Skip to content

OCTO-951: Add ability to escalate to Sentry - #130

Merged
dcaddell merged 4 commits into
masterfrom
OCTO-951_add_sentry_to_possible_external_destinations
Aug 6, 2026
Merged

OCTO-951: Add ability to escalate to Sentry#130
dcaddell merged 4 commits into
masterfrom
OCTO-951_add_sentry_to_possible_external_destinations

Conversation

@dcaddell

Copy link
Copy Markdown
Contributor

Ran ExceptionHandling.log_error("exception handling integration test") from a local Web Rails console pointed at this version of the gem.

See the result here: https://invoca-dev.sentry.io/issues/7652731279/?referrer=issue-stream

Co-authored-by: Cursor <cursoragent@cursor.com>
CopilotAI review requested due to automatic review settings August 4, 2026 22:26
@dcaddell
dcaddell requested a review from a team as a code ownerAugust 4, 2026 22:26

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds optional Sentry escalation to the exception_handling gem so applications that initialize Sentry can receive error notifications alongside (or during migration from) Honeybadger.

Changes:

  • Send Sentry notifications from send_external_notifications when the Sentry constant is defined, with filter-based allow/deny behavior.
  • Introduce send_to_sentry as a new exception filter flag (default false) and add ExceptionInfo#send_to_sentry? migration logic (send to Sentry when send_to_honeybadger: true).
  • Update documentation, changelog, version bump, and add unit tests covering the new Sentry behavior.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
spec/unit/exception_handling/exception_info_spec.rbAdds unit tests for ExceptionInfo#send_to_sentry? behavior and filter interactions.
spec/unit/exception_handling/exception_description_spec.rbAdds unit test coverage for the new send_to_sentry filter flag defaulting to false.
spec/unit/exception_handling_spec.rbAdds integration-style specs validating when Sentry notifications are (and aren’t) sent and failure behavior.
README.mdDocuments Honeybadger/Sentry behavior and filter flag semantics.
lib/exception_handling/version.rbBumps gem version to 3.2.0.
lib/exception_handling/exception_info.rbAdds send_to_sentry? decision logic.
lib/exception_handling/exception_description.rbAdds send_to_sentry configuration and reader.
lib/exception_handling.rbImplements Sentry notification send path and sentry_defined?.
Gemfile.lockUpdates locked gem version to 3.2.0.
CHANGELOG.mdAdds 3.2.0 release entry describing Sentry support and filter behavior.

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

Comment on lines +274 to +276
rescue Exception => ex
warn("ExceptionHandling.send_exception_to_sentry rescued exception while logging #{exception_info.exception_context}:\n#{exception.class}: #{exception.message}:\n#{ex.class}: #{ex.message}\n#{ex.backtrace.join("\n")}")
write_exception_to_log(ex, "ExceptionHandling.send_exception_to_sentry rescued exception while logging #{exception_info.exception_context}:\n#{exception.class}: #{exception.message}", exception_info.timestamp)
Comment on lines +82 to +83
ExceptionHandling.sentry_defined? && (
!exception_description ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why would we send the exception to sentry if the exception_description is nil/false?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

A nil exception_description means that that the exception isn't in the exception filters, so we default to notifying sentry/honeybadger.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh that is definitely strange...

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah the naming is pretty weird but I don't want to boil the ocean. For the sake of this PR, I think it does fine to show that "the sentry integration works how the honeybadger integration works".

Comment on lines 280 to +292
#
# Check if Honeybadger defined.
#
def honeybadger_defined?
Object.const_defined?("Honeybadger")
end

#
# Check if Sentry defined.
#
def sentry_defined?
Object.const_defined?("Sentry")
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is a good pattern we want to follow here. Honeybadger when required automatically setup a bunch of rails callbacks and things that didn't want to do. I wonder if Sentry doesn't do that and we can use some other level instead of if Sentry object is defined.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Good point. I'll look into something better

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

How does this look? ca83d5d

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I definitely like this a lot better!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the plan to have the the services that use sentry to initialize it themselves first then enable it here?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah. For example, to test it locally I added ExceptionHandling.enable_sentry to the bottom of the initializer in Web.

@unblockedunblockedBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found.

About Unblocked

Unblocked has been set up to automatically review your team's pull requests to identify genuine bugs and issues.

📖 Documentation — Learn more in our docs.

💬 Ask questions — Mention @unblocked to request a review or summary, or ask follow-up questions.

👍 Give feedback — React to comments with 👍 or 👎 to help us improve.

⚙️ Customize — Adjust settings in your preferences.

Comment threadlib/exception_handling.rb
@codecov

codecovBot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.03%. Comparing base (2b0c752) to head (02e5ba1).

⚠️Current head 02e5ba1 differs from pull request most recent head 3953423

Please upload reports for the commit 3953423 to get more accurate results.

Files with missing linesPatch %Lines
lib/exception_handling/version.rb0.00%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## master #130 +/- ##
==========================================
+ Coverage 93.58% 94.03% +0.45% 
==========================================
Files 9 9 Lines 483 520 +37 ==========================================
+ Hits 452 489 +37 
Misses 31 31 
Files with missing linesCoverage Δ
lib/exception_handling.rb93.69% <100.00%> (+1.01%)⬆️
lib/exception_handling/exception_description.rb92.85% <100.00%> (+0.26%)⬆️
lib/exception_handling/exception_info.rb99.27% <100.00%> (+0.01%)⬆️
lib/exception_handling/version.rb0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dcaddell
dcaddell requested a review from ttstarckAugust 5, 2026 22:29
@dcaddell
dcaddell merged commit f854d07 into masterAug 6, 2026
6 of 9 checks passed
@dcaddell
dcaddell deleted the OCTO-951_add_sentry_to_possible_external_destinations branch August 6, 2026 16:48
Sign up for freeto 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.

4 participants

@dcaddell@jebentier@ttstarck