Search in sources :

Example 11 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName in project newrelic-java-agent by newrelic.

the class ApiTest method testGetBrowserTimingShortFooterForIgnoredTransaction.

@Test
public void testGetBrowserTimingShortFooterForIgnoredTransaction() throws Exception {
    ApiTestHelper.mockOutServiceManager();
    Transaction tx = Transaction.getTransaction();
    TransactionNamePriority expectedPriority = TransactionNamePriority.FILTER_NAME;
    PriorityTransactionName ptn = PriorityTransactionName.create("name", null, expectedPriority);
    tx.setPriorityTransactionName(ptn);
    BasicRequestRootTracer tracer = createDispatcherTracer();
    tx.getTransactionActivity().tracerStarted(tracer);
    tx.setIgnore(true);
    NewRelic.getBrowserTimingHeader();
    String browserTimingFooter = NewRelic.getBrowserTimingFooter();
    Assert.assertEquals("Incorrect short header", "", browserTimingFooter);
    tx.getTransactionActivity().tracerFinished(tracer, 0);
}
Also used : Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) BasicRequestRootTracer(com.newrelic.agent.tracers.servlet.BasicRequestRootTracer) TransactionNamePriority(com.newrelic.agent.bridge.TransactionNamePriority) BrowserConfigTest(com.newrelic.agent.browser.BrowserConfigTest) Test(org.junit.Test)

Example 12 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName in project newrelic-java-agent by newrelic.

the class TransactionNamingTest method ignoreTransaction.

@Test
public void ignoreTransaction() throws Exception {
    startWebTransaction("/dude/test/man");
    Transaction tx = Transaction.getTransaction();
    PriorityTransactionName ptn = tx.getPriorityTransactionName();
    tx.setIgnore(true);
    tx.getDispatcher().setTransactionName();
    Assert.assertEquals(ptn, tx.getPriorityTransactionName());
}
Also used : Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) Test(org.junit.Test)

Example 13 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName in project newrelic-java-agent by newrelic.

the class TransactionNamingTest method transactionNameAlreadySet.

@Test
public void transactionNameAlreadySet() throws Exception {
    startWebTransaction("/dude/test/man");
    String normalizedUri = "/dude2/test2/man2";
    Transaction tx = Transaction.getTransaction();
    TransactionNamingPolicy policy = TransactionNamingPolicy.getSameOrHigherPriorityTransactionNamingPolicy();
    policy.setTransactionName(tx, normalizedUri, null, TransactionNamePriority.CUSTOM_HIGH);
    PriorityTransactionName ptn = tx.getPriorityTransactionName();
    tx.getDispatcher().setTransactionName();
    Assert.assertEquals(ptn, tx.getPriorityTransactionName());
}
Also used : Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) TransactionNamingPolicy(com.newrelic.agent.transaction.TransactionNamingPolicy) Test(org.junit.Test)

Example 14 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName in project newrelic-java-agent by newrelic.

the class AgentTest method normalRequestWithFilter.

@Test
public void normalRequestWithFilter() throws ServletException, Exception {
    final String applicationName = APPLICATION_NAME_2;
    TestServlet servlet = new TestServlet();
    String path = "/my/word";
    Transaction tx = invokeFilter(servlet, new DummyFilter(), "", applicationName, path);
    Set<String> metrics = AgentHelper.getMetrics();
    Assert.assertTrue(metrics.toString(), metrics.contains("Servlet/" + TestServlet.class.getName() + "/service"));
    PriorityTransactionName transactionName = tx.getPriorityTransactionName();
    Assert.assertEquals("WebTransaction/Servlet/TestServlet", transactionName.getName());
}
Also used : NewRelicIgnoreTransaction(test.newrelic.test.agent.TraceAnnotationTest.NewRelicIgnoreTransaction) Transaction(com.newrelic.agent.Transaction) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) Test(org.junit.Test)

Example 15 with PriorityTransactionName

use of com.newrelic.agent.transaction.PriorityTransactionName in project newrelic-java-agent by newrelic.

the class CrossProcessStateCatApiTest method setUpTransaction.

private void setUpTransaction(Transaction tx, TransactionActivity txa, Object lock, Dispatcher dispatcher, CrossProcessConfig config, String guid) {
    when(txa.getTransaction()).thenReturn(tx);
    when(tx.getLock()).thenReturn(lock);
    when(tx.getDispatcher()).thenReturn(dispatcher);
    when(tx.getCrossProcessConfig()).thenReturn(config);
    DistributedTracePayloadImpl distributedTracePayload = DistributedTracePayloadImpl.createDistributedTracePayload("", "", "", 0f);
    when(tx.createDistributedTracePayload(guid)).thenReturn(distributedTracePayload);
    TransactionStats transactionStats = Mockito.mock(TransactionStats.class);
    SimpleStatsEngine stats = Mockito.mock(SimpleStatsEngine.class);
    when(stats.getOrCreateResponseTimeStats(anyString())).thenReturn(Mockito.mock(ResponseTimeStats.class));
    when(transactionStats.getUnscopedStats()).thenReturn(stats);
    when(txa.getTransactionStats()).thenReturn(transactionStats);
    when(tx.getTransactionActivity()).thenReturn(txa);
    InboundHeaders headers = Mockito.mock(InboundHeaders.class);
    InboundHeaderState inboundHeaderState = new InboundHeaderState(tx, headers);
    when(tx.getInboundHeaderState()).thenReturn(inboundHeaderState);
    PriorityTransactionName priorityTransactionName = PriorityTransactionName.create("Something/Or/other", "category", TransactionNamePriority.FRAMEWORK);
    when(tx.getPriorityTransactionName()).thenReturn(priorityTransactionName);
    TransactionCounts txnCounts = Mockito.mock(TransactionCounts.class);
    when(txnCounts.isOverTracerSegmentLimit()).thenReturn(false);
    when(tx.getTransactionCounts()).thenReturn(txnCounts);
}
Also used : ResponseTimeStats(com.newrelic.agent.stats.ResponseTimeStats) TransactionStats(com.newrelic.agent.stats.TransactionStats) PriorityTransactionName(com.newrelic.agent.transaction.PriorityTransactionName) InboundHeaders(com.newrelic.api.agent.InboundHeaders) SimpleStatsEngine(com.newrelic.agent.stats.SimpleStatsEngine) TransactionCounts(com.newrelic.agent.transaction.TransactionCounts) DistributedTracePayloadImpl(com.newrelic.agent.tracing.DistributedTracePayloadImpl)

Aggregations

PriorityTransactionName (com.newrelic.agent.transaction.PriorityTransactionName)26 Test (org.junit.Test)21 Transaction (com.newrelic.agent.Transaction)19 TransactionNamePriority (com.newrelic.agent.bridge.TransactionNamePriority)14 BasicRequestRootTracer (com.newrelic.agent.tracers.servlet.BasicRequestRootTracer)14 ArrayList (java.util.ArrayList)7 BrowserConfigTest (com.newrelic.agent.browser.BrowserConfigTest)5 ResponseTimeStats (com.newrelic.agent.stats.ResponseTimeStats)3 TransactionStats (com.newrelic.agent.stats.TransactionStats)3 AgentConfig (com.newrelic.agent.config.AgentConfig)2 SimpleStatsEngine (com.newrelic.agent.stats.SimpleStatsEngine)2 DistributedTracePayloadImpl (com.newrelic.agent.tracing.DistributedTracePayloadImpl)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 NewRelicIgnoreTransaction (test.newrelic.test.agent.TraceAnnotationTest.NewRelicIgnoreTransaction)2 TransactionData (com.newrelic.agent.TransactionData)1 TransactionListener (com.newrelic.agent.TransactionListener)1 BrowserMonitoringConfig (com.newrelic.agent.config.BrowserMonitoringConfig)1 DistributedTracingConfig (com.newrelic.agent.config.DistributedTracingConfig)1 Dispatcher (com.newrelic.agent.dispatchers.Dispatcher)1