如何将获救的异常发送到 NewRelic ?

我有一个测试文件 rpm.rb:

require 'newrelic_rpm'
NewRelic::Agent.manual_start
begin
  "2" + 3
rescue TypeError => e
  puts "whoa !"
  NewRelic::Agent.agent.error_collector.notice_error( e )
end

我从以下开始:
NEWRELIC_ENABLE=true ruby rpm.rb

log/newrelic_agent.log 的内容:
[05/14/13 ... (87691)] INFO : Reading configuration from config/newrelic.yml
[05/14/13 ... (87691)] INFO : Environment: development
[05/14/13 ... (87691)] WARN : No dispatcher detected.
[05/14/13 ... (87691)] INFO : Application: xxx (Development)
[05/14/13 ... (87691)] INFO : Installing Net instrumentation
[05/14/13 ... (87691)] INFO : Audit log enabled at '.../log/newrelic_audit.log'
[05/14/13 ... (87691)] INFO : Finished instrumentation
[05/14/13 ... (87691)] INFO : Reading configuration from config/newrelic.yml
[05/14/13 ... (87691)] INFO : Starting Agent shutdown

log/newrelic_audit.log 的内容
[2013-05-14 ... (87691)] : REQUEST: collector.newrelic.com:443/agent_listener/12/74901a11b7ff1a69aba11d1797830c8c1af41d56/get_redirect_host?marshal_format=json
[2013-05-14 ... (87691)] : REQUEST BODY: []

什么都没有报告给 NewRelic,为什么?

我已经看到了:Is there way to push NewRelic error manually?

最佳答案

您需要在 config/newrelic.yml 中设置 monitor_mode: true

development:
  <<: *default_settings
  # Turn off communication to New Relic service in development mode (also
  # 'enabled').
  # NOTE: for initial evaluation purposes, you may want to temporarily
  # turn the agent on in development mode.
  monitor_mode: true

  # Rails Only - when running in Developer Mode, the New Relic Agent will
  # present performance information on the last 100 transactions you have
  # executed since starting the mongrel.
  # NOTE: There is substantial overhead when running in developer mode.
  # Do not use for production or load testing.
  developer_mode: true

关于ruby - 如何手动向 NewRelic (Ruby) 发送异常?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16539013/

10-13 02:08