Package com.newrelic.api.agent
Interface ErrorGroupCallback
-
public interface ErrorGroupCallback
Classes that implement this interface are used to generate grouping keys for errors that will be sent to New Relic. These keys will be used to group error messages in the Errors Inbox UI. Only one callback can be registered at a time.
An instance of this class is registered via theNewRelic.setErrorGroupCallback(ErrorGroupCallback)
method. For errors that will be reported to New Relic, the generateGroupingString method is called with an instance ofErrorData
. The ErrorData instance contains information about the target error, such as the error message, error class, transaction name, stack trace, etc (some information may not be available, depending on if the error was captured in a transaction or not).
For example, this implementation of the generateGroupingString method will generate a key based on the error class and the transaction name. If either one of those properties is empty, it will return null, which will prevent a grouping key from being assigned. Note that all the methods in ErrorData will never return null, just empty Strings or empty maps/arrays, exceptErrorData.getException()
.public class MyErrorGrouper implements ErrorGroupCallback { public String generateGroupingString(ErrorData errorData) { String clazz = errorData.getErrorClass(); String txnName = errorDate.getTransactionName(); return (clazz.isEmpty() || txnName.isEmpty()) ? null : clazz + "_" + txnName } }
//Register error grouping key generator with the agent ErrorGroupCallback myErrorGrouper = new MyErrorGrouper(); NewRelic.setErrorGroupCallback(myErrorGrouper);
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
generateGroupingString(ErrorData errorData)
Method used to generate a grouping key, utilizing the data from the suppliedErrorData
instance.
-
-
-
Method Detail
-
generateGroupingString
java.lang.String generateGroupingString(ErrorData errorData)
Method used to generate a grouping key, utilizing the data from the suppliedErrorData
instance.- Parameters:
errorData
- the ErrorData instance that contains information about the error that will be reported to New Relic.- Returns:
- the key that will be used to group error messages in the Errors Inbox. If null, no grouping key will be assigned.
-
-