use of com.newrelic.agent.instrumentation.methodmatchers.InvalidMethodDescriptor in project newrelic-java-agent by newrelic.
the class ErrorServiceImpl method getEnabledErrorHandlerPointCuts.
public static Collection<? extends PointCut> getEnabledErrorHandlerPointCuts() {
AgentConfig config = ServiceFactory.getConfigService().getDefaultAgentConfig();
Object exceptionHandlers = config.getErrorCollectorConfig().getExceptionHandlers();
Collection<PointCut> pointcuts = new ArrayList<>();
if (exceptionHandlers instanceof Collection<?>) {
for (Object sigObject : ((Collection<?>) exceptionHandlers)) {
if (sigObject instanceof ExceptionHandlerSignature) {
ExceptionHandlerSignature exHandlerSig = (ExceptionHandlerSignature) sigObject;
String msg = MessageFormat.format("Instrumenting exception handler signature {0}", exHandlerSig.toString());
Agent.LOG.finer(msg);
ExceptionHandlerPointCut pc = new ExceptionHandlerPointCut(exHandlerSig);
if (pc.isEnabled()) {
pointcuts.add(pc);
}
} else if (sigObject instanceof String) {
ClassMethodSignature signature = PointCutFactory.parseClassMethodSignature(sigObject.toString());
try {
ExceptionHandlerSignature exHandlerSig = new ExceptionHandlerSignature(signature);
Agent.LOG.info(MessageFormat.format("Instrumenting exception handler signature {0}", exHandlerSig.toString()));
ExceptionHandlerPointCut pc = new ExceptionHandlerPointCut(exHandlerSig);
if (pc.isEnabled()) {
pointcuts.add(pc);
}
} catch (InvalidMethodDescriptor e) {
Agent.LOG.severe(MessageFormat.format("Unable to instrument exception handler {0} : {1}", sigObject.toString(), e.toString()));
}
} else if (sigObject instanceof Exception) {
Agent.LOG.severe(MessageFormat.format("Unable to instrument exception handler : {0}", sigObject.toString()));
}
}
}
return pointcuts;
}
Aggregations