Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I ignore particular exceptions in New Relic Java API?

Tags:

newrelic

I am using the New Relic Java API to monitor a Jersey Rest application secured by OAuth.

In our application we throw an exception whenever somebody tries to do something unauthorized. While these are exceptions, they do not need to be monitored by the New Relic Error reporting.

I see on the Java API that there is a method to make sure that an error is reported to New Relic ( https://docs.newrelic.com/docs/java/java-agent-api NewRelic.noticeError(Throwable throwable) )

Is there any way to suppress reporting of a particular type of exception? My idea would be something like NewRelic.ignoreError(Class clazz) where I could mark certain types of exception classes as ignored for reporting.

like image 466
marstonstudio Avatar asked Nov 12 '13 20:11

marstonstudio


People also ask

How do you send errors to New Relic?

To send error data that you are handling in your own code to New Relic, use the Ruby agent API NewRelic::Agent. notice_error call within your error handler.

How does New Relic Java agent work?

With New Relic's Java agent, you can track everything from performance issues to tiny errors within your code. Every minute the agent posts metric timeslice and event data to the New Relic user interface, where the owner of that data can sign in and use the data to see how their website is performing.

What is Newrelic API?

New Relic's REST API lets you retrieve data from and push data to New Relic tools, as well as to configure features and perform delete operations. You can also use the API Explorer to understand the data available to you via the REST API, to obtain curl commands, and to see JSON responses.


1 Answers

I work for New Relic.

While there is no Java Agent API call to ignore an error, I have filed a feature request to create such a call. However, this won't help you in the near term since we won't be able to promise a timeline on when or if we'll implement this.

So, here is the nature of the things our agent calls errors - perhaps you will be able to change your code a bit so that the error is not noticed by our agent? Effectively, once you handle an exception and DO NOT call the noticeError() method, the exception will not be categorized as or recorded as an error in New Relic. Any chance you can add an exception handler to render your 40x pages instead of letting those exceptions go unhandled?

You can also choose to ignoreTransaction() on the entire transaction, which will cause it not to be categorized as an error either. It's suboptimal since preferably you watch all of your production traffic to know when your error handler itself gets slow or ends up creating its own (unexpected) error, but this should work as well.

Finally, you can ignore HTTP status codes and specific exception names in your agent config - either newrelic.yml (if you use client side config) or on your application settings page (https://rpm.newrelic.com/accounts/X/applications/Y/edit) page if you use server side config.

Note that ignoring a status code or exception name via agent config will only prevent the error from being logged individually, but will still add to the error count / Error Rate, upon which you might be alerting; handling the exception or calling ignoreTransaction() will purge it from the error rate as well.

If none of these approaches work for you, we'd be happy to talk with you further, but you should open a support ticket at https://support.newrelic.com , since this isn't the right forum for discussion.

like image 99
fool Avatar answered Nov 28 '22 12:11

fool