Search in sources :

Example 51 with ClassMethodSignature

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

the class TransactionTimesTest method createDefaultTraer.

private DefaultTracer createDefaultTraer(String methodName) {
    Transaction tx = Transaction.getTransaction();
    ClassMethodSignature sig = new ClassMethodSignature(getClass().getName(), methodName, "()V");
    return new DefaultTracer(tx, sig, this);
}
Also used : Transaction(com.newrelic.agent.Transaction) ClassMethodSignature(com.newrelic.agent.tracers.ClassMethodSignature) DefaultTracer(com.newrelic.agent.tracers.DefaultTracer)

Example 52 with ClassMethodSignature

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

Example 53 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature 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);
}
Also used : 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) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) 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) SimpleMetricNameFormat(com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat) MockHttpServletResponse(org.apache.struts.mock.MockHttpServletResponse) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 54 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature 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());
}
Also used : TransactionDataList(com.newrelic.agent.TransactionDataList) 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 55 with ClassMethodSignature

use of com.newrelic.agent.tracers.ClassMethodSignature 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"));
}
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) 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)

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