use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class ApiTest method nameTransactionThenSetRequestAndResponse.
@Test
public void nameTransactionThenSetRequestAndResponse() {
TransactionDataList txList = new TransactionDataList();
ServiceFactory.getTransactionService().addTransactionListener(txList);
Transaction tx = Transaction.getTransaction();
OtherRootTracer tracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("blah"));
Assert.assertEquals(tracer, tx.getTransactionActivity().tracerStarted(tracer));
tracer.nameTransaction(TransactionNamePriority.CUSTOM_HIGH);
Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
NewRelic.setRequestAndResponse(request, response);
tracer.finish(0, null);
Assert.assertEquals("WebTransaction/Custom/test.newrelic.test.agent.api.ApiTest/", tx.getPriorityTransactionName().getName());
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class TransactionDispatcherTest method testSetResponseOnly.
@Test
public void testSetResponseOnly() {
Transaction tx = Transaction.getTransaction(true);
/* Start a tracer and end it so that the transaction runs the dispatcher
transactionActivityWithResponseFinished code
*/
OtherRootTracer rootTracer = new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), null, new SimpleMetricNameFormat(""));
tx.getTransactionActivity().tracerStarted(rootTracer);
MockHttpResponse response = new MockHttpResponse();
response.setResponseStatus(418);
response.setResponseStatusMessage("tea");
tx.setWebResponse(response);
rootTracer.finish(null);
assertEquals(418, tx.getStatus());
assertEquals("tea", tx.getStatusMessage());
// Make sure the status code was set in time for the Apdex calculation.
StatsEngine statsEngine = ServiceFactory.getStatsService().getStatsEngineForHarvest(tx.getApplicationName());
assertEquals(1, statsEngine.getApdexStats(MetricName.create(MetricNames.APDEX)).getApdexFrustrating());
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class IntrospectorImplTest method createDefaultTracer.
// Create a Tracer for tests that require one.
public static DefaultTracer createDefaultTracer(String methodName) {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature("MyClass", methodName, "()V");
DefaultTracer brrt = new DefaultTracer(tx, sig, new Object(), new SimpleMetricNameFormat("Custom/" + methodName));
return brrt;
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class TransactionStateImplTest method createRootTracer.
private Tracer createRootTracer() throws Exception {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), "dude", "()V");
return new OtherRootTracer(tx, sig, this, new SimpleMetricNameFormat("test"));
}
use of com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat in project newrelic-java-agent by newrelic.
the class TransactionTest method createBasicTracer.
private DefaultTracer createBasicTracer(String id) {
Transaction tx = Transaction.getTransaction();
ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), id, "()V");
return new DefaultTracer(tx, sig, this, new SimpleMetricNameFormat("Custom/myname" + id));
}
Aggregations