Closed
Description
openedon Sep 15, 2022
Issue Description
I'm using Sentry.with_scope
to add custom context information for the piece of code.
Also, I don't want to have Sentry initialized during my tests run. I achieved it by bailing out of sentry initializer before Sentry.init
is called.
It works fine except one thing. Now, code inside with_scope
block is not executed at all. This behavior obviously breaks the application.
Reproduction Steps
config/initializers/sentry.rb
:
return if Rails.env.test? # Don't initialize in test environment
Sentry.init do |config|
config.dsn = 'MY_DSN'
end
Expected Behavior
Code flow should not be affected regardless of the Sentry SDK state.
$ bundle exec rails r "Sentry.with_scope { puts 'Inside the scope' }"
Inside the scope
$
$ RAILS_ENV=test bundle exec rails r "Sentry.with_scope { puts 'Inside the scope' }"
Inside the scope
$
Actual Behavior
$ bundle exec rails r "Sentry.with_scope { puts 'Inside the scope' }"
Inside the scope
$
$ RAILS_ENV=test bundle exec rails r "Sentry.with_scope { puts 'Inside the scope' }"
$
In a nutshell, when I'm in a test environment (Sentry.init
was not called), my code is not working.
Ruby Version
3.0.4
SDK Version
5.4.2
Integration and Its Version
sentry-ruby (5.4.2)
Sentry Config
No response
Activity