You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
The text was updated successfully, but these errors were encountered:
@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 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 👍
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
The text was updated successfully, but these errors were encountered: