use of com.newrelic.agent.instrumentation.classmatchers.ClassMatcher 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.ClassMatcher in project newrelic-java-agent by newrelic.
the class ClassNameFilter method addClassMatcherIncludes.
public void addClassMatcherIncludes(Collection<ClassMatcher> classMatchers) {
Set<String> classNames = new HashSet<>();
classNames.addAll(includeClasses);
for (ClassMatcher classMatcher : classMatchers) {
for (String className : classMatcher.getClassNames()) {
classNames.add(className);
}
}
logger.finer("Class name inclusions: " + classNames);
includeClasses = classNames;
}
use of com.newrelic.agent.instrumentation.classmatchers.ClassMatcher in project newrelic-java-agent by newrelic.
the class InstrumentationConstructorTest method andOrClassMatchers.
@Test
public void andOrClassMatchers() throws Exception {
String classes = "[ !exact_class_matcher 'java/lang/Dude', !exact_class_matcher 'java/lang/Object' ]";
ClassMatcher[] matchers = new ClassMatcher[] { new ExactClassMatcher("java/lang/Dude"), new ExactClassMatcher("java/lang/Object") };
AndClassMatcher classMatcher = load("!and_class_matcher " + classes);
Assert.assertEquals(new AndClassMatcher(matchers), classMatcher);
ClassMatcher orClassMatcher = load("!or_class_matcher " + classes);
Assert.assertEquals(OrClassMatcher.getClassMatcher(matchers), orClassMatcher);
}
use of com.newrelic.agent.instrumentation.classmatchers.ClassMatcher in project newrelic-java-agent by newrelic.
the class ExtensionConversionUtilityTest method createClassMatcher.
@Test
public void createClassMatcher() throws XmlException {
Pointcut pointcut = new Pointcut();
ClassName name = new ClassName();
name.setValue(ArrayList.class.getName());
pointcut.setClassName(name);
ClassMatcher classMatcher = ExtensionConversionUtility.createClassMatcher(pointcut, "test");
Assert.assertTrue(classMatcher instanceof ExactClassMatcher);
Assert.assertTrue(classMatcher.isMatch(ArrayList.class));
}
use of com.newrelic.agent.instrumentation.classmatchers.ClassMatcher in project newrelic-java-agent by newrelic.
the class YmlExtensionPointCutConverter method createExtensionPointCut.
public static ExtensionClassAndMethodMatcher createExtensionPointCut(Map attrs, String defaultMetricPrefix, ClassLoader classLoader, String extName) {
ClassMatcher classMatcher = getClassMatcher(attrs);
MethodMatcher methodMatcher = getMethodMatcher(attrs);
boolean dispatcher = getDispatcher(attrs);
Config newConfig = new BaseConfig(attrs);
boolean skipTransTrace = newConfig.getProperty(SKIP_TRANS_KEY, Boolean.FALSE);
boolean ignoreTrans = newConfig.getProperty(IGNORE_TRANS_KEY, Boolean.FALSE);
String metricPrefix = defaultMetricPrefix;
String metricName;
Object format = attrs.get(METRIC_NAME_FORMAT_KEY);
if (format instanceof String) {
metricName = format.toString();
} else if (null == format) {
metricName = null;
} else if (format instanceof MetricNameFormatFactory) {
// sorry - not supported anymore
Agent.LOG.log(Level.WARNING, MessageFormat.format("The object property {0} is no longer supported in the agent. The default naming mechanism will be used.", METRIC_NAME_FORMAT_KEY));
metricName = null;
} else {
throw new RuntimeException(MessageFormat.format("Unsupported {0} value", METRIC_NAME_FORMAT_KEY));
}
String tracerFactoryNameString = getTracerFactoryName(attrs, defaultMetricPrefix, dispatcher, format, classLoader);
String nameOfExtension = (extName == null) ? "Unknown" : extName;
return new ExtensionClassAndMethodMatcher(nameOfExtension, metricName, metricPrefix, classMatcher, methodMatcher, dispatcher, skipTransTrace, false, ignoreTrans, tracerFactoryNameString);
}
Aggregations