我正在尝试配置空气制动器,但无法弄明白。我想要达到的目的不是仅从生产中获得development
和test
envs的错误。
通过以下设置,我得到了生产中出现的所有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)
答案 0 :(得分:2)
您可以像这样配置被忽略的环境:
c.ignore_environments = %w(test, development)
# Which is equivalent to:
c.ignore_environments = ['test,', 'development']
配置此选项的正确方法是:
c.ignore_environments = %w(test development)
# Which is equivalent to:
c.ignore_environments = ['test', 'development']
如果对数组使用Ruby的%w
语法,则不要使用逗号。
另一个潜在的问题是您指定:
c.environment = :production
在这里使用字符串(而不是符号)或Rails.env
会更健壮。
c.environment = Rails.env