0
我试图配置airbrake,但无法弄清楚。我想要达到的目标不是从生产中获得仅来自development
和test
envs的错误。用于heroku +导轨的airbrake配置
用下面的设置,虽然,我得到的所有3种类型的错误消息,因为他们在生产中发生。因此生产错误发送生产错误通知,但是开发/测试错误也发送生产错误通知。
如何正确配置它?
# Configures the environment the application is running in. Helps the Airbrake
# dashboard to distinguish between exceptions occurring in different
# environments. By default, it's not set.
# NOTE: This option must be set in order to make the 'ignore_environments'
# option work.
# https://github.com/airbrake/airbrake-ruby#environment
c.environment = :production
# Setting this option allows Airbrake to filter exceptions occurring in
# unwanted environments such as :test. By default, it is equal to an empty
# Array, which means Airbrake Ruby sends exceptions occurring in all
# environments.
# NOTE: This option *does not* work if you don't set the 'environment' option.
# https://github.com/airbrake/airbrake-ruby#ignore_environments
c.ignore_environments = %w(test, development)
kyrylo,hahaha。为了确保它能够正确地发回数组,我甚至把它放在'irb'中。不知怎的,我错过了:)。 'c.environment =:production'来自官方文档。当涉及到Rails.env时,我感到困惑。文档说'默认情况下,它没有设置,但默认值是'Rails.env',这似乎与我矛盾。 –
默认情况下,airbrake-ruby作为库不会对其进行设置。但airbrake gem有一个Rails初始化程序,它知道Rails应用程序很可能会使用'Rails.env',所以它可以方便地为您配置。至于文档,它们也使用'ignore_environments'的符号,所以这种行为在那里是一致的。快乐制动! – kyrylo