use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class DatabaseServiceTest method instanceLocalhostReplace.
@Test
public void instanceLocalhostReplace() throws Exception {
Map<String, Object> configMap = createStagingMap();
Map<String, Object> dsConfigMap = createMap();
dsConfigMap.put(DatastoreConfigImpl.INSTANCE_REPORTING, true);
configMap.put(AgentConfigImpl.DATASTORE_TRACER, dsConfigMap);
createServiceManager(configMap);
final Connection connection = Mockito.mock(Connection.class);
DatastoreInstanceDetection.detectConnectionAddress();
DatastoreInstanceDetection.associateAddress(connection, new InetSocketAddress("localhost", 8080));
DatastoreInstanceDetection.stopDetectingConnectionAddress();
Transaction transaction = Transaction.getTransaction(true);
ClassMethodSignature sig = new ClassMethodSignature("com.foo.Statement", "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;");
TestDefaultSqlTracer tracer = new TestDefaultSqlTracer(transaction, sig, null, new SimpleMetricNameFormat(null), DefaultTracer.DEFAULT_TRACER_FLAGS);
tracer.setRawSql("select * from metrics");
AgentHelper.setLastTracer(tracer);
tracer.provideConnection(connection);
ConnectionFactory connectionFactory = createConnectionFactory(connection);
tracer.setConnectionFactory(connectionFactory);
tracer.finish(Opcodes.ARETURN, new DummyResultSet());
String notExpectedRollupMetricName = getScopedInstanceDBMetric(DatastoreVendor.MySQL.name(), "localhost", "8080");
Assert.assertFalse(tracer.getRolledUpMetricNamesForTesting().contains(notExpectedRollupMetricName));
String expectedRollupMetricName = getScopedInstanceDBMetric(DatastoreVendor.MySQL.name(), DatastoreMetrics.HOSTNAME, "8080");
Assert.assertTrue(String.format("Expected instance metric %s found", expectedRollupMetricName), tracer.getRolledUpMetricNamesForTesting().contains(expectedRollupMetricName));
Transaction.clearTransaction();
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class DatabaseServiceTest method instanceDisabled.
@Test
public void instanceDisabled() throws Exception {
Map<String, Object> configMap = createStagingMap();
Map<String, Object> dbConfigMap = createMap();
Map<String, Object> nestedMap = new HashMap<>();
nestedMap.put(DatastoreConfigImpl.ENABLED, !DatastoreConfigImpl.INSTANCE_REPORTING_DEFAULT_ENABLED);
dbConfigMap.put(DatastoreConfigImpl.INSTANCE_REPORTING, nestedMap);
configMap.put(AgentConfigImpl.DATASTORE_TRACER, dbConfigMap);
createServiceManager(configMap);
final Connection connection = Mockito.mock(Connection.class);
Transaction transaction = Transaction.getTransaction(true);
ClassMethodSignature sig = new ClassMethodSignature("com.foo.Statement", "executeQuery", "(Ljava/lang/String;)Ljava/sql/ResultSet;");
TestDefaultSqlTracer tracer = new TestDefaultSqlTracer(transaction, sig, null, new SimpleMetricNameFormat(null), DefaultTracer.DEFAULT_TRACER_FLAGS);
ConnectionFactory connectionFactory = createConnectionFactory(connection);
tracer.setConnectionFactory(connectionFactory);
tracer.setRawSql("select * from metrics");
tracer.provideConnection(connection);
AgentHelper.setLastTracer(tracer);
tracer.finish(Opcodes.ARETURN, new DummyResultSet());
String expectedRollupMetricName = getScopedInstanceDBMetric(DatastoreVendor.MySQL.name(), "unknown", "unknown");
Assert.assertFalse(tracer.getRolledUpMetricNamesForTesting().contains(expectedRollupMetricName));
Transaction.clearTransaction();
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class AbstractPriorityTransactionNamingPolicyTest method startOtherTransaction.
private void startOtherTransaction() throws Exception {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("", "", "");
MetricNameFormat format = new SimpleMetricNameFormat("");
Tracer tracer = new OtherRootTracer(tx, sig, this, format);
tx.getTransactionActivity().tracerStarted(tracer);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class AsyncTimeoutTransactionTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
}
use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.
the class AsyncTransactionTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private BasicRequestRootTracer createDispatcherTracer(String methodName) {
Transaction tx = Transaction.getTransaction();
MockHttpRequest httpRequest = new MockHttpRequest();
MockHttpResponse httpResponse = new MockHttpResponse();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
BasicRequestRootTracer brrt = new BasicRequestRootTracer(tx, sig, this, httpRequest, httpResponse);
tx.setDispatcher(brrt.createDispatcher());
return brrt;
}
Aggregations