It is currently not possible to mark transaction error as expected from the agent api.
The use case for this is that we have false alerts triggered from “expected” errors that we cannot whitelist with the current configuration options. We have error handler component that will log some thrown exceptions as errors and some as warnings and ignore some completely. All of those end up as counted errors in new relic although we would like to have alerts only from actual non-expected errors.
The error rules are not enough, we cannot just categorically ignore specific error or based on message contents, same error in different context might be a real problem and in other context not. Only viable way would be to tell to new relic to ignore (or set as expected) the thrown error in same code logic where we decide how to handle the error in application.
Calling noticeError does not work since the exception that instrumentation has already seen takes precedence over errors reported with noticeError and there can be only one error per transaction.
Setting the “ignoreErrorPriority: false” as suggested here: https://stackoverflow.com/a/30782791/1227867 does not work since you also have stated here NoticeError is ignored on ErrorController - Grails that “We’ve began to use that API call within our own code now so, depending on the instrumentation detecting the error, this may or may not work.”.
If the instrumentation is the first one to call noticeError, then calling it again inside the same transaction has no effect
So I would like to have a way inside a transaction to call the java agent api to ignore errors in current transaction. It could also still report them as expected as long as they do not increase the error count.
add some kind of setTransactionErrorAsExpected to agent api that is similar with ignoreTransaction. If there will be error in the transaction it will get marked as expected in NR. It should be possible to call this at any phase inside the transaction, not just beginning, to be able to call it in your error handler catch logic just before transaction is ending.
add some kind of support to prioritise noticeError over the automatically noticed transaction error or override it. Maybe if expected=true then it would override any noticeError calls that have been made for the transaction where expected=false or not specified. Basically add a way to get around the “first caller wins” logic.
New Relic Edit
- I want this too
- I have more info to share (reply below)
- I have a solution for this
We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.