Search in sources :

Example 61 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.

the class ApiTest method testSetTransactionNameMoreThanOnce.

@Test
public void testSetTransactionNameMoreThanOnce() {
    Transaction tx = Transaction.getTransaction();
    tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
    NewRelic.setTransactionName("Test", "/foo");
    NewRelic.setTransactionName("Test", "/dude");
    NewRelic.setTransactionName("Test", "/bar");
    Assert.assertEquals("OtherTransaction/Test/bar", tx.getPriorityTransactionName().getName());
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 62 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature in project newrelic-java-agent by newrelic.

the class ApiTest method testIgnoreTransactionNotSet.

@Test
public void testIgnoreTransactionNotSet() {
    Transaction tx = Transaction.getTransaction();
    tx.getTransactionActivity().tracerStarted(new OtherRootTracer(tx, new ClassMethodSignature("", "", ""), this, new SimpleMetricNameFormat("dude")));
    Assert.assertTrue("Transaction should be ignored", !tx.isIgnore());
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 63 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature 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());
}
Also used : MockHttpServletResponse(org.apache.struts.mock.MockHttpServletResponse) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse) Response(com.newrelic.api.agent.Response) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) HttpServletResponse(javax.servlet.http.HttpServletResponse) TransactionDataList(com.newrelic.agent.TransactionDataList) Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) MockHttpServletRequest(org.apache.struts.mock.MockHttpServletRequest) ExtendedRequest(com.newrelic.api.agent.ExtendedRequest) Request(com.newrelic.api.agent.Request) MockHttpRequest(com.newrelic.agent.tracers.servlet.MockHttpRequest) MockHttpServletRequest(org.apache.struts.mock.MockHttpServletRequest) HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) MockHttpServletResponse(org.apache.struts.mock.MockHttpServletResponse) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 64 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature 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());
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) StatsEngine(com.newrelic.agent.stats.StatsEngine) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) MockHttpResponse(com.newrelic.agent.tracers.servlet.MockHttpResponse) Test(org.junit.Test)

Example 65 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature 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;
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)

Aggregations

ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)112 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)69 Transaction (com.newrelic.agent.Transaction)60 Test (org.junit.Test)55 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)46 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)44 Tracer (com.newrelic.agent.tracers.Tracer)41 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)26 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)23 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)20 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)17 HashMap (java.util.HashMap)17 TransactionData (com.newrelic.agent.TransactionData)16 JSONObject (org.json.simple.JSONObject)15 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)13 UltraLightTracer (com.newrelic.agent.tracers.UltraLightTracer)12 JSONArray (org.json.simple.JSONArray)11 MethodExitTracer (com.newrelic.agent.tracers.MethodExitTracer)10 Response (com.newrelic.api.agent.Response)10 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)9