0

我正在尝试配置空气制动,但无法弄清楚。我想要实现的不仅仅是从生产中获取错误development和环境。test

但是,通过以下设置,我会收到所有 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)
4

1 回答 1

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
于 2016-05-12T14:35:42.147 回答