use of com.newrelic.agent.tracers.OtherRootTracer in project newrelic-java-agent by newrelic.
the class CrossProcessTransactionStateImplTest method testRendersBothHeaders.
@Test
public void testRendersBothHeaders() {
CrossProcessTransactionStateImpl crossProcessTransactionState = setupTestForDistributedTracing(true);
OutboundHeadersMap headers = new OutboundHeadersMap(HeaderType.HTTP);
crossProcessTransactionState.populateRequestMetadata(headers, new OtherRootTracer(ta, new ClassMethodSignature("my.class", "methodname", "something"), "object", null));
assertTrue(headers.containsKey("newrelic"));
assertTrue(headers.get("newrelic").length() > 0);
assertTrue(headers.containsKey("traceparent"));
assertTrue(headers.get("traceparent").length() > 0);
assertTrue(headers.containsKey("tracestate"));
assertTrue(headers.get("tracestate").length() > 0);
}
use of com.newrelic.agent.tracers.OtherRootTracer 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.OtherRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method testTransactionTimes.
@Test
public void testTransactionTimes() throws InterruptedException {
Transaction tx = Transaction.getTransaction();
OtherRootTracer root = createDispatcherTracer();
tx.getTransactionActivity().tracerStarted(root);
DefaultTracer tracer1 = createDefaultTraer("hello1");
tx.getTransactionActivity().tracerStarted(tracer1);
DefaultTracer tracer2 = createDefaultTraer("hello2");
tx.getTransactionActivity().tracerStarted(tracer2);
Thread.sleep(10);
tracer2.finish(0, null);
tracer1.finish(0, null);
root.finish(0, null);
Assert.assertNotNull(stats);
SimpleStatsEngine unscoped = stats.getUnscopedStats();
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransaction/all"));
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/all"));
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransaction/myMetricName"));
Assert.assertNotNull(unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/myMetricName"));
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransaction/all").getCallCount());
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime").getCallCount());
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransaction/myMetricName").getCallCount());
Assert.assertEquals(1, unscoped.getOrCreateResponseTimeStats("OtherTransactionTotalTime/myMetricName").getCallCount());
SimpleStatsEngine scoped = stats.getScopedStats();
Assert.assertNotNull(scoped.getOrCreateResponseTimeStats("Java/com.newrelic.agent.transaction.TransactionTimesTest/dude"));
Assert.assertEquals(1, scoped.getOrCreateResponseTimeStats("Java/com.newrelic.agent.transaction.TransactionTimesTest/dude").getCallCount());
Assert.assertEquals(root.getDuration(), tx.getTransactionTimer().getTotalSumTimeInNanos());
Assert.assertEquals(root.getDuration(), tx.getTransactionTimer().getResponseTimeInNanos());
Assert.assertEquals(1, tx.getFinishedChildren().size());
}
use of com.newrelic.agent.tracers.OtherRootTracer in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method createDispatcherTracer.
// Create a Tracer for tests that require one.
private OtherRootTracer createDispatcherTracer() {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new OtherRootTracer(tx, sig, this, new OtherTransSimpleMetricNameFormat("myMetricName"));
}
use of com.newrelic.agent.tracers.OtherRootTracer in project newrelic-java-agent by newrelic.
the class ApiTest method setRequestAndResponseFirstWins.
@Test
public void setRequestAndResponseFirstWins() throws Exception {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("otherRootTracer"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
Request firstRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "firstWins", "", ""));
Response firstResponse = new FirstResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(firstRequest, firstResponse);
Request secondRequest = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "thisIsABug", "", ""));
Response secondResponse = new SecondResponse(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(secondRequest, secondResponse);
tracer.finish(0, null);
Assert.assertEquals(firstRequest.getRequestURI(), tx.getDispatcher().getUri());
Assert.assertEquals(firstResponse.getStatus(), ((WebRequestDispatcher) tx.getDispatcher()).getStatus());
String name = tx.getPriorityTransactionName().getName();
Assert.assertNotEquals("WebTransaction/Uri/thisIsABug", name);
Assert.assertEquals("WebTransaction/Uri/firstWins", name);
}
Aggregations