Search in sources :

Example 26 with OtherRootTracer

use of com.newrelic.agent.tracers.OtherRootTracer 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 27 with OtherRootTracer

use of com.newrelic.agent.tracers.OtherRootTracer 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)

Example 28 with OtherRootTracer

use of com.newrelic.agent.tracers.OtherRootTracer 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);
}
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 29 with OtherRootTracer

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

the class ApiTest method testSetRequestAndResponse.

@Test
public void testSetRequestAndResponse() {
    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));
    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(1, txList.size());
    Assert.assertEquals("/mytest", txList.get(0).getRequestUri(AgentConfigImpl.ATTRIBUTES));
    TransactionStats stats = apiTestHelper.tranStats;
    ResponseTimeStats dispatcherStats = stats.getUnscopedStats().getOrCreateResponseTimeStats("HttpDispatcher");
    Assert.assertEquals(1, dispatcherStats.getCallCount());
    Assert.assertEquals(1, stats.getUnscopedStats().getOrCreateResponseTimeStats("WebTransaction/Uri/mytest").getCallCount());
    Assert.assertEquals(1, stats.getUnscopedStats().getApdexStats("Apdex/Uri/mytest").getApdexSatisfying());
    Assert.assertEquals(1, stats.getUnscopedStats().getApdexStats("Apdex").getApdexSatisfying());
    Assert.assertEquals(1, stats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.WEB_TRANSACTION).getCallCount());
    Assert.assertEquals(0, stats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.OTHER_TRANSACTION_ALL).getCallCount());
}
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) ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) TransactionDataList(com.newrelic.agent.TransactionDataList) TransactionStats(com.newrelic.agent.stats.TransactionStats) 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 30 with OtherRootTracer

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

the class ApiTest method testSetRequestAndResponseThenSetTxName.

@Test
public void testSetRequestAndResponseThenSetTxName() {
    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));
    Request request = new ApiTestHelper.RequestWrapper(new MockHttpServletRequest("/", "mytest", "", "&test=dude"));
    Response response = new ApiTestHelper.ResponseWrapper(new MockHttpServletResponse());
    NewRelic.setRequestAndResponse(request, response);
    NewRelic.setTransactionName("Test", "Foo");
    tracer.finish(0, null);
    Assert.assertEquals("WebTransaction/Test/Foo", 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)

Aggregations

OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)51 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)45 Transaction (com.newrelic.agent.Transaction)35 SimpleMetricNameFormat (com.newrelic.agent.tracers.metricname.SimpleMetricNameFormat)34 Test (org.junit.Test)31 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)17 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)15 Tracer (com.newrelic.agent.tracers.Tracer)15 MockHttpResponse (com.newrelic.agent.tracers.servlet.MockHttpResponse)11 Response (com.newrelic.api.agent.Response)10 MockHttpRequest (com.newrelic.agent.tracers.servlet.MockHttpRequest)9 MetricNameFormat (com.newrelic.agent.tracers.metricname.MetricNameFormat)8 ExtendedRequest (com.newrelic.api.agent.ExtendedRequest)8 Request (com.newrelic.api.agent.Request)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)8 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)8 MockHttpServletRequest (org.apache.struts.mock.MockHttpServletRequest)8 MockHttpServletResponse (org.apache.struts.mock.MockHttpServletResponse)8 TransactionDataList (com.newrelic.agent.TransactionDataList)6