【发布时间】:2013-05-08 11:42:54
【问题描述】:
如何将已获救的异常发送到 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 没有任何报告,为什么?
【问题讨论】:
-
raise关键字有帮助吗? -
我不想让我们的客户看到堆栈跟踪 :),这就是为什么在我的示例中进行救援的原因,但是谢谢
-
这可能太明显了,但是NR在开发模式下默认不会打电话回家,除非你改变配置文件。
-
这似乎被
WARN : No dispatcher detected.证实了 -
我在 New Relic 的 newrelic_rpm gem 上工作。您使用的是什么版本的 newrelic_rpm gem?除非检测到已知的调度程序(Web 服务器或后台任务框架),否则旧版本将完全拒绝启动,并且看起来您可能已经成功了。此外,您应该使用
NewRelic::Agent.notice_error,因为这是我们的公共 API,而不是 error_collector 上的版本。