use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method testDisplayHostAttribute.
@Test
public void testDisplayHostAttribute() throws Exception {
Map<String, Object> configMap = createConfigMap();
Map<String, Object> values = new HashMap<>();
values.put("display_name", "onetwothree");
configMap.put("process_host", values);
createServiceManager(configMap);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
Thread.sleep(10);
tx.getTransactionActivity().tracerStarted(rootTracer);
finishTransaction(tx, rootTracer);
assertEquals(3, tx.getAgentAttributes().size());
String actualDisplayName = (String) tx.getAgentAttributes().get("host.displayName");
assertNotNull(actualDisplayName);
assertEquals("onetwothree", actualDisplayName);
assertNotNull(tx.getAgentAttributes().get("jvm.thread_name"));
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method checkRunningDuration.
@Test
public void checkRunningDuration() throws Exception {
createServiceManager(createConfigMap());
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
tx.getTransactionActivity().tracerStarted(rootTracer);
long firstTime = tx.getRunningDurationInNanos();
Thread.sleep(2);
finishTransaction(tx, rootTracer);
long endTime = tx.getRunningDurationInNanos();
assertTrue(endTime > firstTime);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method addUserParams.
@Test
public void addUserParams() throws Exception {
Map<String, Object> configMap = createConfigMap();
createServiceManager(configMap);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
Thread.sleep(40);
tx.getTransactionActivity().tracerStarted(rootTracer);
tx.getUserAttributes().put("key1", "value1");
finishTransaction(tx, rootTracer);
Long cpuTime = (Long) tx.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME);
assertNotNull(cpuTime);
assertTrue(cpuTime > 0);
assertEquals(2, tx.getAgentAttributes().size());
assertNotNull(tx.getAgentAttributes().get("jvm.thread_name"));
assertEquals(1, tx.getUserAttributes().size());
assertEquals("value1", tx.getUserAttributes().get("key1"));
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method recordCpuAndGCTimeWithLegacyIsNotReported.
@Test
public void recordCpuAndGCTimeWithLegacyIsNotReported() throws Exception {
Map<String, Object> configMap = createConfigMap();
createServiceManager(configMap);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
Thread.sleep(40);
tx.getTransactionActivity().tracerStarted(rootTracer);
tx.addTotalCpuTimeForLegacy(TransactionActivity.NOT_REPORTED);
rootTracer.finish(Opcodes.ARETURN, null);
tx.recordFinalGCTime(tx.getTransactionActivity().getTransactionStats());
Long cpuTime = (Long) tx.getIntrinsicAttributes().get(AttributeNames.CPU_TIME_PARAMETER_NAME);
// should not be reported
assertNull(cpuTime);
}
use of com.newrelic.agent.tracers.servlet.BasicRequestRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTest method testInstanceNameAttribute.
@Test
public void testInstanceNameAttribute() throws Exception {
Map<String, Object> configMap = createConfigMap();
configMap.put("instance_name", "MyInstanceName");
createServiceManager(configMap);
Transaction.clearTransaction();
Transaction tx = Transaction.getTransaction();
BasicRequestRootTracer rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
Thread.sleep(10);
tx.getTransactionActivity().tracerStarted(rootTracer);
finishTransaction(tx, rootTracer);
assertEquals(3, tx.getAgentAttributes().size());
String actualInstanceName = (String) tx.getAgentAttributes().get("process.instanceName");
assertNotNull(actualInstanceName);
assertEquals("MyInstanceName", actualInstanceName);
assertNotNull(tx.getAgentAttributes().get("jvm.thread_name"));
configMap = createConfigMap();
createServiceManager(configMap);
Transaction.clearTransaction();
tx = Transaction.getTransaction();
rootTracer = (BasicRequestRootTracer) createDispatcherTracer(true);
Thread.sleep(10);
tx.getTransactionActivity().tracerStarted(rootTracer);
finishTransaction(tx, rootTracer);
assertEquals(2, tx.getAgentAttributes().size());
actualInstanceName = (String) tx.getAgentAttributes().get("process.instanceName");
assertNull(actualInstanceName);
assertNotNull(tx.getAgentAttributes().get("jvm.thread_name"));
}
Aggregations