use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat 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.metricname.SimpleMetricNameFormat 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);
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ApiTest method setRequestAndResponseNullRequestResponse.
@Test
public void setRequestAndResponseNullRequestResponse() {
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));
NewRelic.setRequestAndResponse(null, null);
Assert.assertFalse(tx.isWebRequestSet());
Assert.assertFalse(tx.isWebResponseSet());
tracer.finish(0, null);
Assert.assertTrue(tx.isWebTransaction());
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ApiTest method testSetUserName.
@Test
public void testSetUserName() {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
NewRelic.setUserName("myname");
Assert.assertEquals("myname", tx.getUserAttributes().get("user"));
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ApiTest method testNoExceptionRecordMetric.
@Test
public void testNoExceptionRecordMetric() throws Exception {
Transaction tx = Transaction.getTransaction();
tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
String name = "roger";
tx.getTransactionActivity().getTransactionStats().getUnscopedStats().getApdexStats(name);
try {
tx.getTransactionActivity().getTransactionStats().getUnscopedStats().getStats(name);
Assert.fail("expected java.lang.RuntimeException");
} catch (RuntimeException e) {
// expected
}
NewRelic.recordMetric("roger", 1.0f);
}
Aggregations