use of com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher in project newrelic-java-agent by newrelic.
the class ExtensionConversionUtility method createPointCut.
/**
* Converts the xml point cut into a java agent point cut.
*
* @return The point cut object with the matchers set.
*/
private static ExtensionClassAndMethodMatcher createPointCut(Extension extension, final Pointcut cut, final String metricPrefix, final String pName, final Map<String, MethodMapper> classesToMethods, boolean custom, InstrumentationType type, boolean isAttsEnabled) throws XmlException {
ClassMatcher classMatcher;
if (cut.getMethodAnnotation() != null) {
classMatcher = new AllClassesMatcher();
} else {
classMatcher = createClassMatcher(cut, pName);
}
MethodMatcher methodMatcher = createMethodMatcher(cut, pName, classesToMethods);
List<ParameterAttributeName> reportedParams = null;
if (!isAttsEnabled) {
// looks like this could be modified later
reportedParams = new ArrayList<>();
} else {
reportedParams = getParameterAttributeNames(cut.getMethod());
}
return new ExtensionClassAndMethodMatcher(extension, cut, metricPrefix, classMatcher, methodMatcher, custom, reportedParams, type);
}
use of com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher in project newrelic-java-agent by newrelic.
the class ClassesMatcherTest method getMatchingClasses_ReturnType.
@Trace
@Test
public void getMatchingClasses_ReturnType() {
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new ExactReturnTypeMethodMatcher(Type.getType(List.class)))).build();
Set<Class<?>> matchingClasses = ClassesMatcher.getMatchingClasses(Collections.singletonList(matcher), matcherHelper, Arrays.class, ArrayList.class, HashMap.class, TestClass.class, Proxy.class);
assertEquals(3, matchingClasses.size());
assertTrue(matchingClasses.contains(ArrayList.class));
assertTrue(matchingClasses.contains(TestClass.class));
assertTrue(matchingClasses.contains(Arrays.class));
}
use of com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher in project newrelic-java-agent by newrelic.
the class ClassesMatcherTest method getMatchingClasses_Annotation.
@Trace
@Test
public void getMatchingClasses_Annotation() {
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new AnnotationMethodMatcher(Type.getType(Trace.class)))).build();
Set<Class<?>> matchingClasses = ClassesMatcher.getMatchingClasses(Collections.singletonList(matcher), matcherHelper, ClassesMatcherTest.class, ArrayList.class, HashMap.class);
assertEquals(1, matchingClasses.size());
assertTrue(matchingClasses.contains(ClassesMatcherTest.class));
}
Aggregations