-
-
Notifications
You must be signed in to change notification settings - Fork 494
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
Don't do anything in Sentry unless enabled_in_current_env? #1682
Conversation
Otherwise Sentry can sometimes cause errors when trying to capture exceptions in tests, when `test` is not an enabled environment. This has occurred for me when my system reaches its `ulimit` during many, many subsequent app requests in Capybara tests, which manifests as `RuntimeError: failed to get urandom`. Because Sentry captures the app exception, and then starts to build reporting around it, it also runs code that causes `RuntimeError: failed to get urandom`. I then end up with a test failure report that only shows the trace of the Sentry exception, not the original app exception. Therefore I think this can be avoided by not doing anything in Sentry unless it's enabled for the current environment, because everything it does would end up being thrown away, if my thinking is correct? For example: ``` Failure/Error: ret = Random.urandom(n) RuntimeError: failed to get urandom # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/event.rb:34:in `initialize' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/client.rb:54:in `new' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/client.rb:54:in `event_from_exception' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/hub.rb:99:in `capture_exception' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry-ruby.rb:181:in `capture_exception' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/integrable.rb:15:in `capture_exception' # /Users/me/path/to/gems/sentry-rails-4.7.3/lib/sentry/rails/capture_exceptions.rb:30:in `capture_exception' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/rack/capture_exceptions.rb:28:in `rescue in block in call' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/rack/capture_exceptions.rb:22:in `block in call' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/hub.rb:56:in `with_scope' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry-ruby.rb:176:in `with_scope' # /Users/me/path/to/gems/sentry-ruby-core-4.7.3/lib/sentry/rack/capture_exceptions.rb:14:in `call' # /Users/me/path/to/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call' # /Users/me/path/to/gems/rack-cors-1.1.1/lib/rack/cors.rb:100:in `call' # /Users/me/path/to/gems/railties-6.0.4.1/lib/rails/engine.rb:527:in `call' # /Users/me/path/to/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call' # /Users/me/path/to/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each' # /Users/me/path/to/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call' # /Users/me/path/to/gems/capybara-3.32.2/lib/capybara/server/middleware.rb:58:in `call' # /Users/me/path/to/gems/puma-5.5.1/lib/puma/configuration.rb:249:in `call' # /Users/me/path/to/gems/puma-5.5.1/lib/puma/request.rb:77:in `block in handle_request' # /Users/me/path/to/gems/puma-5.5.1/lib/puma/thread_pool.rb:340:in `with_force_shutdown' # /Users/me/path/to/gems/puma-5.5.1/lib/puma/request.rb:76:in `handle_request' # /Users/me/path/to/gems/puma-5.5.1/lib/puma/server.rb:447:in `process_client' # /Users/me/path/to/gems/puma-5.5.1/lib/puma/thread_pool.rb:147:in `block in spawn_thread' # ------------------ # --- Caused by: --- # RuntimeError: # failed to get urandom # /Users/me/path/to/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call' ```
Codecov Report
@@ Coverage Diff @@
## master #1682 +/- ##
==========================================
+ Coverage 98.46% 98.50% +0.03%
==========================================
Files 136 136
Lines 7667 7667
==========================================
+ Hits 7549 7552 +3
+ Misses 118 115 -3
Continue to review full report at Codecov.
|
This should fix #1683 |
This would fix an issue I'm having as well! Same issue as AppSignal just fixed: appsignal/appsignal-ruby#684 |
As I explained in #1683, I think this fix isn't the best solution for the problem and the other fix has been released in |
Otherwise Sentry can sometimes cause errors when trying to capture exceptions in tests, when
test
is not an enabled environment.This has occurred for me when my system reaches its
ulimit
during many, many subsequent app requests in Capybara tests, which manifests asRuntimeError: failed to get urandom
. Because Sentry captures the app exception, and then starts to build reporting around it, it also runs code that causesRuntimeError: failed to get urandom
.I then end up with a test failure report that only shows the trace of the Sentry exception, not the original app exception. Therefore I think this can be avoided by not doing anything in Sentry unless it's enabled for the current environment, because everything it does would end up being thrown away, if my thinking is correct?
For example:
Thanks for your Pull Request 🎉
Please keep these instructions in mind so we can review it more efficiently:
Other Notes
Description
Describe your changes: