Sentry -未定义的方法[]在Rails上为nil



最近我们开始出现很多错误,这些错误在Sentry中不可见,但在我们的日志中可以看到。

你知道该怎么做吗?

#<NoMethodError: undefined method `[]' for nil:NilClass>
2021-02-23T10:12:16.063361+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/transaction.rb:32:in `from_sentry_trace'
2021-02-23T10:12:16.063361+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:21:in `block in call'
2021-02-23T10:12:16.063362+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/hub.rb:52:in `with_scope'
2021-02-23T10:12:16.063363+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry-ruby.rb:149:in `with_scope'
2021-02-23T10:12:16.063363+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:14:in `call'
2021-02-23T10:12:16.063364+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.063364+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
2021-02-23T10:12:16.063365+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.063365+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:227:in `call'
2021-02-23T10:12:16.063366+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:660:in `handle_request'
2021-02-23T10:12:16.063366+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:474:in `process_client'
2021-02-23T10:12:16.063366+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
2021-02-23T10:12:16.063367+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'
2021-02-23T10:12:16.121258+00:00 app[web.2]: ** [NewRelic][2021-02-23 10:12:16 +0000 web.2 (4)] WARN : The error reporting queue has reached 20. The error detail for this and subsequent errors will not be transmitted to New Relic until the queued errors have been sent: undefined method `[]' for nil:NilClass
2021-02-23T10:12:16.123804+00:00 app[web.2]: 2021-02-23 10:12:16 +0000: Rack app error handling request { GET /stream/dasdfa/traffic.*****.com/secure/dddd/*****.mp3 }
2021-02-23T10:12:16.123806+00:00 app[web.2]: #<NoMethodError: undefined method `[]' for nil:NilClass>
2021-02-23T10:12:16.123807+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/transaction.rb:32:in `from_sentry_trace'
2021-02-23T10:12:16.123807+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:21:in `block in call'
2021-02-23T10:12:16.123808+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/hub.rb:52:in `with_scope'
2021-02-23T10:12:16.123808+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry-ruby.rb:149:in `with_scope'
2021-02-23T10:12:16.123809+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/sentry-ruby-core-4.1.6/lib/sentry/rack/capture_exceptions.rb:14:in `call'
2021-02-23T10:12:16.123809+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.123810+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:524:in `call'
2021-02-23T10:12:16.123810+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/newrelic_rpm-6.5.0.357/lib/new_relic/agent/instrumentation/middleware_tracing.rb:99:in `call'
2021-02-23T10:12:16.123811+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/configuration.rb:227:in `call'
2021-02-23T10:12:16.123811+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:660:in `handle_request'
2021-02-23T10:12:16.123811+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:474:in `process_client'
2021-02-23T10:12:16.123812+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/server.rb:334:in `block in run'
2021-02-23T10:12:16.123812+00:00 app[web.2]: /app/vendor/bundle/ruby/2.6.0/gems/puma-3.12.1/lib/puma/thread_pool.rb:135:in `block in spawn_thread'

哨兵初始化脚本

Sentry.init do |config|
config.dsn = 'https://***@****.ingest.sentry.io/***'
config.breadcrumbs_logger = [:active_support_logger]
config.enabled_environments = %w[production]
end

错误消失后,我从应用程序中删除哨兵显然看起来像哨兵是负责的事件。但是为什么呢?

请升级到最新版本,我们修复了一个错误。

最新更新