use of com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher in project newrelic-java-agent by newrelic.
the class InstrumentationImpl method instrument.
@Override
public void instrument(String className, String metricPrefix) {
DefaultClassAndMethodMatcher matcher = new HashSafeClassAndMethodMatcher(new ExactClassMatcher(className), AndMethodMatcher.getMethodMatcher(new AccessMethodMatcher(Opcodes.ACC_PUBLIC), new NotMethodMatcher(GetterSetterMethodMatcher.getGetterSetterMethodMatcher())));
ServiceFactory.getClassTransformerService().addTraceMatcher(matcher, metricPrefix);
}
use of com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher in project newrelic-java-agent by newrelic.
the class OptimizedClassMatcherTest method before.
@Before
public void before() {
initializeServiceManager();
OptimizedClassMatcherBuilder builder = OptimizedClassMatcherBuilder.newBuilder();
match1 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Collection.class), new ExactMethodMatcher("size", "()I"));
match2 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(List.class), new ExactMethodMatcher("get", "(I)Ljava/lang/Object;"));
match3 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(InvocationHandler.class), new ExactMethodMatcher("invoke", "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"));
match4 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Statement.class), new AllMethodsMatcher());
match5 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Runnable.class), OrMethodMatcher.getMethodMatcher(new NameMethodMatcher("run"), new ExactMethodMatcher("bogus", "()V")));
match6 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Map.class), new AccessMethodMatcher(Opcodes.ACC_PUBLIC));
match7 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(List.class), new ExactMethodMatcher("add", "(Ljava/lang/Object;)Z"));
annotationMatch = new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new AnnotationMethodMatcher(Type.getType(MyAnnotation.class)));
// this is a bogus matcher to attempt to throw off match5
builder.addClassMethodMatcher(new DefaultClassAndMethodMatcher(createInterfaceMatcher(PreparedStatement.class), new NameMethodMatcher("run")));
builder.addClassMethodMatcher(match1);
builder.addClassMethodMatcher(match2);
builder.addClassMethodMatcher(match3);
builder.addClassMethodMatcher(match4);
builder.addClassMethodMatcher(match5);
builder.addClassMethodMatcher(match6);
builder.addClassMethodMatcher(match7);
builder.addClassMethodMatcher(annotationMatch);
this.matcher = builder.build();
}
Aggregations