use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class SlowQueryInfoTest method testEmptyTxnUrlRequestUriDisabled.
@Test
public void testEmptyTxnUrlRequestUriDisabled() {
Map<String, Object> attributeMap = new HashMap<>();
attributeMap.put("exclude", "request.*");
Map<String, Object> settings = new HashMap<>();
settings.put("attributes", attributeMap);
setupServiceManager(settings);
SqlTraceConfig sqlTraceConfig = ServiceFactory.getConfigService().getDefaultAgentConfig().getSqlTraceConfig();
Transaction transaction = Transaction.getTransaction();
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setUri("http://jvm.agent.uri");
transaction.setDispatcher(dispatcher);
TransactionData data = new TransactionData(transaction, 100);
Tracer tracer = new DefaultTracer(transaction, new ClassMethodSignature("ClassName", "methodName", "methodDesc"), null, null, TracerFlags.DISPATCHER);
SlowQueryInfo slowQueryInfo = new SlowQueryInfo(data, tracer, "select * from person", "select ? from ?", sqlTraceConfig);
SqlTrace sqlTrace = slowQueryInfo.asSqlTrace();
assertEquals(null, sqlTrace.getUri());
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class SlowQueryInfoTest method testTxnUrl.
@Test
public void testTxnUrl() {
setupServiceManager(new HashMap<String, Object>());
Transaction transaction = Transaction.getTransaction();
SqlTraceConfig sqlTraceConfig = ServiceFactory.getConfigService().getDefaultAgentConfig().getSqlTraceConfig();
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setUri("http://jvm.agent.uri");
transaction.setDispatcher(dispatcher);
TransactionData data = new TransactionData(transaction, 100);
Tracer tracer = new DefaultTracer(transaction, new ClassMethodSignature("ClassName", "methodName", "methodDesc"), null, null, TracerFlags.DISPATCHER);
SlowQueryInfo slowQueryInfo = new SlowQueryInfo(data, tracer, "select * from person", "select ? from ?", sqlTraceConfig);
SqlTrace sqlTrace = slowQueryInfo.asSqlTrace();
assertEquals("http://jvm.agent.uri", sqlTrace.getUri());
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class AsyncTest method verifyCpu.
public void verifyCpu(long minCpu) {
Assert.assertNotNull(data);
Assert.assertNotNull(data.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME));
Long val = (Long) data.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME);
Assert.assertTrue("The cpu should be greater than 0", val > 0);
Assert.assertTrue("The cpu should be greater than the expeted min value " + minCpu, val > minCpu);
long cpuTime = 0L;
Collection<Tracer> tracers = new HashSet<>();
tracers.add(data.getRootTracer());
tracers.addAll(data.getTracers());
Collection<TransactionActivity> txas = new HashSet<>();
// collect all txas for the transaction
for (Tracer current : tracers) {
if (current instanceof TransactionActivityInitiator) {
txas.add(((DefaultTracer) current).getTransactionActivity());
}
}
for (TransactionActivity txa : txas) {
cpuTime += txa.getTotalCpuTime();
}
Assert.assertEquals("The cpu should be sum of txa cpus ", cpuTime, val.longValue());
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class ExternalRequestImplTest method getTracer.
private DefaultTracer getTracer(String metricName, String transactionSegName) {
MetricNameFormat format = new SimpleMetricNameFormat(metricName, transactionSegName);
DefaultTracer tracer = new DefaultTracer(Transaction.getTransaction(), new ClassMethodSignature("class", "method", "()V"), new Object(), format);
return tracer;
}
use of com.newrelic.agent.tracers.DefaultTracer in project newrelic-java-agent by newrelic.
the class ExternalsForTransactionTest method createTracer.
private DefaultTracer createTracer(String metricName, String txSegName) {
Transaction tx = Transaction.getTransaction();
SimpleMetricNameFormat format = new SimpleMetricNameFormat(metricName, txSegName);
DefaultTracer tracer = new DefaultTracer(tx, new ClassMethodSignature("myClass", "myMethod", "()V"), this, format);
return tracer;
}
Aggregations