Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set sentry.error_event_id in request env if the middleware captures errors #1849

Merged
merged 2 commits into from
Jul 21, 2022

Conversation

st0012
Copy link
Collaborator

@st0012 st0012 commented Jul 20, 2022

It will allow users/libraries to implement mechanisms displaying relevant error events' ids. Which will help their users report issues.

Closes #1846

@st0012 st0012 added this to the 5.4.0 milestone Jul 20, 2022
@st0012 st0012 self-assigned this Jul 20, 2022
@st0012 st0012 added this to In progress in 5.x via automation Jul 20, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2022

Codecov Report

Merging #1849 (83c9b7e) into master (2f3e11a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1849   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         146      146           
  Lines        8735     8744    +9     
=======================================
+ Hits         8595     8604    +9     
  Misses        140      140           
Impacted Files Coverage Δ
...entry-rails/lib/sentry/rails/capture_exceptions.rb 96.42% <100.00%> (+0.13%) ⬆️
sentry-rails/spec/sentry/rails_spec.rb 84.86% <100.00%> (+0.30%) ⬆️
sentry-ruby/lib/sentry/rack/capture_exceptions.rb 95.34% <100.00%> (+0.22%) ⬆️
...y-ruby/spec/sentry/rack/capture_exceptions_spec.rb 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f3e11a...83c9b7e. Read the comment docs.

@@ -32,7 +32,9 @@ def capture_exception(exception, env)
current_scope.set_transaction_name(original_transaction)
end

Sentry::Rails.capture_exception(exception)
Sentry::Rails.capture_exception(exception).tap do |event|
env[ERROR_EVENT_ID_KEY] = event.event_id if event
Copy link

Choose a reason for hiding this comment

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

this should also go into the rack middleware here ?

def capture_exception(exception, _env)
Sentry.capture_exception(exception)
def capture_exception(exception, env)
Sentry.capture_exception(exception).tap do |event|
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@grosser This also has the same logic.
I had to replicate them in 2 places because the receivers are different: Sentry and Sentry::Rails and I don't want to introduce another abstraction just for the 2 occurrences.

Copy link
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.

nice, very useful!

@st0012 st0012 merged commit e55cbf1 into master Jul 21, 2022
5.x automation moved this from In progress to Done Jul 21, 2022
@st0012 st0012 deleted the implement-#1846 branch July 21, 2022 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
5.x
Done
Development

Successfully merging this pull request may close these issues.

rails: allow showing link to sentry page on error page
4 participants