Issue Description
Errors that happen within Jobs are not sent to Sentry when using sentry-rails and sentry-resque
The problem was encountered after upgrading our app to Rails 7 and Ruby 3.0.2
We upgraded:
sentry-ruby from '~> 4.6.5', to '~> 5.1.1'
sentry-rails from '~> 4.6.5', to '~> 5.1.1'
And we switched from our own fork of resque-sentry to sentry-resque', '~> 5.1.1'
We noticed after a while, errors from whithin our jobs are no longer reported to Sentry.
I tried to hunt down the bug and here is what I found so far. Some facts beforehand:
Reproduction Steps
I forked the repository and changed the Rails 7.0 example app of sentry-rails in a way to make it possible to reproduce the issue described above.
The diff of the fork can be found here (I did not open a PR as this does not contain a fix):
master...flowdgmbh:no-resque-events-example
- Clone the fork
cd sentry-ruby/sentry-rails/examples/rails-7.0
bundle install
- Change the dsn in
sentry-rails/examples/rails-7.0/config/initializers/sentry.rb
- RAILS_ENV=development COUNT=1 QUEUE=* bundle exec rake resque:workers
- In another terminal schedule a job with
bundle exec rails runner 'ErrorJob.perform_later'
Expected Behavior
The error is reported to sentry
Actual Behavior
The following happens for us when an error occours in the job (in the context of the separate Reqsue worker):
Result: No error was sent to Sentry
Ruby Version
3.1.0
SDK Version
5.1.1
Integration and Its Version
No response
Sentry Config
No response
Issue Description
Errors that happen within Jobs are not sent to Sentry when using
sentry-railsandsentry-resqueThe problem was encountered after upgrading our app to Rails 7 and Ruby 3.0.2
We upgraded:
sentry-rubyfrom'~> 4.6.5', to'~> 5.1.1'sentry-railsfrom'~> 4.6.5', to'~> 5.1.1'And we switched from our own fork of
resque-sentrytosentry-resque', '~> 5.1.1'We noticed after a while, errors from whithin our jobs are no longer reported to Sentry.
I tried to hunt down the bug and here is what I found so far. Some facts beforehand:
config.background_worker_threads > 0the option `{hint: {background: false}} is needed for capture_exception/capture_messageresque:workersrake taskReproduction Steps
I forked the repository and changed the Rails 7.0 example app of sentry-rails in a way to make it possible to reproduce the issue described above.
The diff of the fork can be found here (I did not open a PR as this does not contain a fix):
master...flowdgmbh:no-resque-events-example
cd sentry-ruby/sentry-rails/examples/rails-7.0bundle installsentry-rails/examples/rails-7.0/config/initializers/sentry.rbbundle exec rails runner 'ErrorJob.perform_later'Expected Behavior
The error is reported to sentry
Actual Behavior
The following happens for us when an error occours in the job (in the context of the separate Reqsue worker):
Sentry::Rails::ActiveJobExtensionsdecides the error is handled by an integration (sentry-resque) in https://github.com/getsentry/sentry-ruby/blob/master/sentry-rails/lib/sentry/rails/active_job.rb#L5Sentry::Rails::ErrorSubscribergets the error via instrumentation and callscapture_exception. But it does so without{hint: {background: false}}so no HTTP request is made to Sentrycapture_exceptioncorrectly with `{hint: {background: false}}Result: No error was sent to Sentry
Ruby Version
3.1.0
SDK Version
5.1.1
Integration and Its Version
No response
Sentry Config
No response