Skip to content

Avoid duplicated capturing on the same exception object#1738

Merged
st0012 merged 3 commits intomasterfrom
fix-#1731
Feb 20, 2022
Merged

Avoid duplicated capturing on the same exception object#1738
st0012 merged 3 commits intomasterfrom
fix-#1731

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Feb 20, 2022

As described in #1731, the SDK can have duplicated exception report in Rails 7+ applications because of the new Rails.error support introduced in version 5.1.0.

After a discussion with the feature author, we decided to let whichever mechanism captures the exception first report it (could be either Rails.error or Sentry's integration in different scenarios). Although it's possible that we'd loss some contextual data with Rails.error, the difference is acceptable.

Also, sentry-python already has a similar mechanism to de-dup error reports, so it's been proven to work.

Fixes #1731

@st0012 st0012 added this to the 5.2.0 milestone Feb 20, 2022
@st0012 st0012 requested a review from sl0thentr0py February 20, 2022 12:37
@st0012 st0012 self-assigned this Feb 20, 2022
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 20, 2022

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.39%. Comparing base (27c3a35) to head (6238d6b).
⚠️ Report is 606 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1738   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         141      141           
  Lines        8021     8030    +9     
=======================================
+ Hits         7892     7901    +9     
  Misses        129      129           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@st0012 st0012 modified the milestones: 5.2.0, 5.1.1 Feb 20, 2022
capture_event(event, **options, &block).tap do
# mark the exception as captured so we can use this information to avoid duplicated capturing
exception.instance_variable_set(:@__sentry_captured, true)
exception.instance_variable_set(Sentry::CAPTURED_SIGNATURE, true)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I feel like the logic of Sentry.exception_captured? may be used by users or integrations in the future for checking purpose so I extracted it. But marking exception as captured should only be done here so I didn't add a method for it.

Copy link
Copy Markdown
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

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

thx @st0012, looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate reporting for Sidekiq errors

3 participants