use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.
the class AgentPreprocessorsTest method testRewriteSlowQueryBuilderNoHighSecurity.
@Test
public void testRewriteSlowQueryBuilderNoHighSecurity() throws Exception {
final ClassLoader classloader = Thread.currentThread().getContextClassLoader();
final String classname = "com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessorsTest$ExternalParametersFactoryTestClass5";
Map<String, Object> confProps = new HashMap<>();
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(confProps);
byte[] bytes = getClassBytesFromClassLoaderResource(classname, classloader);
Assert.assertNotNull(bytes);
ClassNode source = WeaveUtils.convertToClassNode(bytes);
ClassNode result = new ClassNode(WeaveUtils.ASM_API_LEVEL);
ClassVisitor cv = new CheckClassAdapter(result);
AgentPreprocessors preprocessors = new AgentPreprocessors(agentConfig, null);
preprocessors.setInstrumentationTitle(INSTRUMENTATION_TITLE);
cv = preprocessors.rewriteSlowQueryIfRequired(cv);
source.accept(cv);
Class<?> clazz = addToClassloader(result, classloader);
Assert.assertNotNull(clazz);
ExternalParametersFactoryTestClass5 testClass = (ExternalParametersFactoryTestClass5) clazz.newInstance();
assertNotNull(testClass);
ExternalParameters regularDatastore = testClass.createRegularDatastore();
assertNotNull(regularDatastore);
assertTrue(regularDatastore instanceof DatastoreParameters);
ExternalParameters slowQueryDatastore = testClass.createSlowQueryDatastore();
assertNotNull(slowQueryDatastore);
assertTrue(slowQueryDatastore instanceof SlowQueryDatastoreParameters);
ExternalParameters slowQueryWithInputDatastore = testClass.createSlowQueryWithInputDatastore();
assertNotNull(slowQueryWithInputDatastore);
assertTrue(slowQueryWithInputDatastore instanceof SlowQueryWithInputDatastoreParameters);
}
use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.
the class AgentPreprocessorsTest method testRewriteSlowQueryBuilderWithHighSecurityAndListToCollect.
@Test
public void testRewriteSlowQueryBuilderWithHighSecurityAndListToCollect() throws Exception {
final ClassLoader classloader = Thread.currentThread().getContextClassLoader();
final String classname = "com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessorsTest$ExternalParametersFactoryTestClass7";
Map<String, Object> confProps = new HashMap<>();
confProps.put("high_security", true);
Map<String, Object> ttConfig = new HashMap<>();
ttConfig.put("collect_slow_queries_from", INSTRUMENTATION_TITLE + ",some-other-module");
confProps.put("transaction_tracer", ttConfig);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(confProps);
byte[] bytes = getClassBytesFromClassLoaderResource(classname, classloader);
Assert.assertNotNull(bytes);
ClassNode source = WeaveUtils.convertToClassNode(bytes);
ClassNode result = new ClassNode(WeaveUtils.ASM_API_LEVEL);
ClassVisitor cv = new CheckClassAdapter(result);
AgentPreprocessors preprocessors = new AgentPreprocessors(agentConfig, null);
preprocessors.setInstrumentationTitle(INSTRUMENTATION_TITLE);
cv = preprocessors.rewriteSlowQueryIfRequired(cv);
source.accept(cv);
Class<?> clazz = addToClassloader(result, classloader);
Assert.assertNotNull(clazz);
ExternalParametersFactoryTestClass7 testClass = (ExternalParametersFactoryTestClass7) clazz.newInstance();
assertNotNull(testClass);
ExternalParameters regularDatastore = testClass.createRegularDatastore();
assertNotNull(regularDatastore);
assertTrue(regularDatastore instanceof DatastoreParameters);
ExternalParameters slowQueryDatastore = testClass.createSlowQueryDatastore();
assertNotNull(slowQueryDatastore);
assertTrue(slowQueryDatastore instanceof SlowQueryDatastoreParameters);
ExternalParameters slowQueryWithInputDatastore = testClass.createSlowQueryWithInputDatastore();
assertNotNull(slowQueryWithInputDatastore);
assertTrue(slowQueryWithInputDatastore instanceof SlowQueryWithInputDatastoreParameters);
}
use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.
the class DynamoDBMetricUtil method metrics.
public static void metrics(TracedMethod tracedMethod, String operation, String collection, URI endpoint) {
String host = endpoint == null ? INSTANCE_HOST : endpoint.getHost();
String port = endpoint == null ? INSTANCE_ID : String.valueOf(getPort(endpoint));
DatastoreParameters params = DatastoreParameters.product(PRODUCT).collection(collection).operation(operation).instance(host, port).noDatabaseName().build();
tracedMethod.reportAsExternal(params);
}
use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.
the class DynamoDBMetricUtil method metrics.
public static void metrics(TracedMethod tracedMethod, String operation, String collection, URI endpoint) {
String host = endpoint == null ? INSTANCE_HOST : endpoint.getHost();
String port = endpoint == null ? INSTANCE_ID : String.valueOf(getPort(endpoint));
DatastoreParameters params = DatastoreParameters.product(PRODUCT).collection(collection).operation(operation).instance(host, port).noDatabaseName().build();
tracedMethod.reportAsExternal(params);
}
use of com.newrelic.api.agent.DatastoreParameters in project newrelic-java-agent by newrelic.
the class AgentPreprocessorsTest method testRewriteSlowQueryNoHighSecurity.
@Test
public void testRewriteSlowQueryNoHighSecurity() throws Exception {
final ClassLoader classloader = Thread.currentThread().getContextClassLoader();
final String classname = "com.newrelic.agent.instrumentation.weaver.preprocessors.AgentPreprocessorsTest$ExternalParametersFactoryTestClass1";
Map<String, Object> confProps = new HashMap<>();
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(confProps);
byte[] bytes = getClassBytesFromClassLoaderResource(classname, classloader);
Assert.assertNotNull(bytes);
ClassNode source = WeaveUtils.convertToClassNode(bytes);
ClassNode result = new ClassNode(WeaveUtils.ASM_API_LEVEL);
ClassVisitor cv = new CheckClassAdapter(result);
AgentPreprocessors preprocessors = new AgentPreprocessors(agentConfig, null);
preprocessors.setInstrumentationTitle(INSTRUMENTATION_TITLE);
cv = preprocessors.rewriteSlowQueryIfRequired(cv);
source.accept(cv);
Class<?> clazz = addToClassloader(result, classloader);
Assert.assertNotNull(clazz);
ExternalParametersFactoryTestClass1 testClass = (ExternalParametersFactoryTestClass1) clazz.newInstance();
assertNotNull(testClass);
ExternalParameters regularDatastore = testClass.createRegularDatastore();
assertNotNull(regularDatastore);
assertTrue(regularDatastore instanceof DatastoreParameters);
ExternalParameters slowQueryDatastore = testClass.createSlowQueryDatastore();
assertNotNull(slowQueryDatastore);
assertTrue(slowQueryDatastore instanceof SlowQueryDatastoreParameters);
ExternalParameters slowQueryWithInputDatastore = testClass.createSlowQueryWithInputDatastore();
assertNotNull(slowQueryWithInputDatastore);
assertTrue(slowQueryWithInputDatastore instanceof SlowQueryWithInputDatastoreParameters);
}
Aggregations