有没有办法手动推送NewRelic错误? [英] Is there way to push NewRelic error manually?

查看:88
本文介绍了有没有办法手动推送NewRelic错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的Rails应用程序中,我们在ApplicationController上挽救了大多数异常,以提供正确的API响应,但仍想跟踪使用ErrorCollector发生的错误.有没有办法将错误手动发送给NewRelic?

In our Rails app we rescue most of the exceptions on ApplicationController to give correct API response, but still want to track errors happening using ErrorCollector. Is there a way to manually send error to NewRelic?

推荐答案

根据我在New Relic代理代码中看到的内容,您可以做

Based on what I see in the New Relic agent code you can do

NewRelic::Agent.notice_error(exception, options)

我已经对此进行了测试,并将其运行在我的堆栈中

I have tested this and have this running in my stack

这是控制器中的一个示例:

Here's an example in a controller:

class ApplicationController < ActionController::Base
  rescue_from ActiveRecord::RecordInvalid, with: :rescue_invalid_record

  private

  def rescue_invalid_record(exception)
    NewRelic::Agent.notice_error(exception)
  end
end

这篇关于有没有办法手动推送NewRelic错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆