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

Exception data is lost in active support instrumentation events #1629

Closed
Linuus opened this issue Nov 23, 2021 · 2 comments · Fixed by #1631
Closed

Exception data is lost in active support instrumentation events #1629

Linuus opened this issue Nov 23, 2021 · 2 comments · Fixed by #1631
Assignees
Projects

Comments

@Linuus
Copy link

Linuus commented Nov 23, 2021

Issue Description

I'm having some issues using Sentry, ActiveJob and LogSubscribers.
We have an ActiveJob log subscriber which logs stuff in production. When an exception occurs in a job, we log it and the instrumentation event payload includes the Exception that was raised.
However, now that we are trying to move over to Sentry, the exception is no longer present in the instrumentation event payload. The reason for this is that here:
https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/lib/sentry/rails/active_job.rb#L36-L39

All exceptions are rescued. The exception is only re-raised if there are no handlers for it. In our case, we have a retry_on handler so the error won't be re-raised. The issue with this though is that ActiveSupport::Notifications::Instrumenter is also rescuing any exceptions that happen and adds the exception information to the event payload, here: https://github.com/rails/rails/blob/8337645e852c7a2f4f112ea03db6fa4e00081c5e/activesupport/lib/active_support/notifications/instrumenter.rb#L25-L27
So, now that Sentry is rescuing the exception, AS instrumenter doesn't get any exception and we lose that information.

This is what the order of "rescues" are:

Is this expected behavior?

Reproduction Steps

Add an active job log subscriber and log event.payload[:exception]
Add a job that has a retry_on handler.
Raise an error in the job that is handled by the retry_on handler.

Expected Behavior

The exception is logged in the log subscriber.

Actual Behavior

The exception is not logged in the log subscriber.

Ruby Version

2.7.3

SDK Version

4.8.0

Integration and Its Version

Sentry Rails 4.8.0

Sentry Config

No response

@st0012 st0012 added this to To do in 4.x via automation Nov 23, 2021
@st0012
Copy link
Collaborator

st0012 commented Nov 27, 2021

@Linuus thanks for reporting the issue. although it's not originally made for this issue, but I think #1631 may fix this as well. can you give it a try? thx

@Linuus
Copy link
Author

Linuus commented Nov 30, 2021

@Linuus thanks for reporting the issue. although it's not originally made for this issue, but I think #1631 may fix this as well. can you give it a try? thx

I haven't been able to try it yet as we added some custom tracing instead.

However, I think that PR would indeed fix the issue 👍

4.x automation moved this from To do to Done Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
4.x
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants