Search in sources :

Example 1 with InvalidMethodDescriptor

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;
}
Also used : PointCut(com.newrelic.agent.instrumentation.PointCut) AgentConfig(com.newrelic.agent.config.AgentConfig) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) ArrayList(java.util.ArrayList) Collection(java.util.Collection) InvalidMethodDescriptor(com.newrelic.agent.instrumentation.methodmatchers.InvalidMethodDescriptor)

Aggregations

AgentConfig (com.newrelic.agent.config.AgentConfig)1 PointCut (com.newrelic.agent.instrumentation.PointCut)1 InvalidMethodDescriptor (com.newrelic.agent.instrumentation.methodmatchers.InvalidMethodDescriptor)1 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1