Is there way to push NewRelic error manually? Is there way to push NewRelic error manually? ruby-on-rails ruby-on-rails

Is there way to push NewRelic error manually?


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)  endend


Not sure if it's recommended way to use, but this works perfectly:

NewRelic::Agent.agent.error_collector.notice_error( exception )


Full documentation of the API call to notice errors and increment the error metric is the New Relic Ruby Agent API documentation here http://rdoc.info/github/newrelic/rpm/NewRelic/Agent/Transaction.notice_error