use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class TransactionEventsServiceTest method testErrorSavesData.
@Test
public void testErrorSavesData() throws Exception {
setup(true, true, TEST_RESERVOIR_SIZE);
TransactionData transactionData = generateTransactionData(APP_NAME);
TransactionStats transactionStats = new TransactionStats();
// populate the eventData map
service.harvestEvents(APP_NAME);
DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = getEventData(APP_NAME);
assertEquals(0, currentEventData.size());
for (int i = 0; i < TEST_RESERVOIR_SIZE * 2; i++) {
service.dispatcherTransactionFinished(transactionData, transactionStats);
}
assertEquals(TEST_RESERVOIR_SIZE * 2, currentEventData.getNumberOfTries());
service.harvestEvents(APP_NAME);
assertEquals(TEST_RESERVOIR_SIZE * 2, currentEventData.getNumberOfTries());
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class TransactionEventsServiceTest method testDisabled.
@Test
public void testDisabled() throws Exception {
setup(false, true, TEST_RESERVOIR_SIZE);
assertFalse(service.isEnabled());
TransactionData transactionData = generateTransactionData(APP_NAME);
TransactionStats transactionStats = new TransactionStats();
// populate the eventData map
service.harvestEvents(APP_NAME);
DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = getEventData(APP_NAME);
assertEquals(0, currentEventData.size());
service.dispatcherTransactionFinished(transactionData, transactionStats);
assertEquals(0, currentEventData.size());
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class TransactionEventsServiceTest method testUserParameters.
@Test
public void testUserParameters() throws Exception {
setup(true, true, TEST_RESERVOIR_SIZE);
Map<String, Object> userParams = new LazyMapImpl<>();
userParams.put("key1", "value1");
userParams.put("key2", "value2");
TransactionData transactionData = generateTransactionDataAndComplete(userParams, APP_NAME);
TransactionStats transactionStats = new TransactionStats();
transactionStats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.DISPATCHER).recordResponseTime(8, TimeUnit.MILLISECONDS);
// populate the eventData map
service.harvestEvents(APP_NAME);
DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = getEventData(APP_NAME);
assertEquals(0, currentEventData.size());
service.dispatcherTransactionFinished(transactionData, transactionStats);
assertEquals(1, currentEventData.size());
final TransactionEvent queueHead = currentEventData.peek();
assertEquals(100f / TimeConversion.MILLISECONDS_PER_SECOND, queueHead.getDuration(), 0);
final Map<String, Object> attributes = queueHead.getUserAttributesCopy();
assertEquals(2, attributes.size());
assertEquals("value1", attributes.get("key1"));
assertEquals("value2", attributes.get("key2"));
service.harvestEvents(APP_NAME);
currentEventData = getEventData(APP_NAME);
assertEquals(0, currentEventData.size());
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class TransactionEventsServiceTest method testSendOther.
@Test
public void testSendOther() throws Exception {
setup(true, true, TEST_RESERVOIR_SIZE);
TransactionActivityInitiator rootTracer = new OtherRootTracer(Transaction.getTransaction(), null, new Object(), null);
TransactionData transactionData = new TransactionDataTestBuilder(APP_NAME, iAgentConfig, new MockDispatcherTracer()).setDispatcher(rootTracer.createDispatcher()).setFrontendMetricName("Frontend/metricname").build();
TransactionStats transactionStats = new TransactionStats();
transactionStats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.DISPATCHER).recordResponseTime(8, TimeUnit.MILLISECONDS);
// populate the eventData map
service.harvestEvents(APP_NAME);
DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = getEventData(APP_NAME);
assertEquals(0, currentEventData.size());
service.dispatcherTransactionFinished(transactionData, transactionStats);
assertEquals(1, currentEventData.size());
}
use of com.newrelic.agent.stats.TransactionStats in project newrelic-java-agent by newrelic.
the class TransactionEventsServiceTest method createAndSendTransaction.
private DistributedSamplingPriorityQueue<TransactionEvent> createAndSendTransaction() {
TransactionData transactionData = generateTransactionData(APP_NAME);
TransactionStats transactionStats = new TransactionStats();
transactionStats.getUnscopedStats().getOrCreateResponseTimeStats(MetricNames.DISPATCHER).recordResponseTime(8, TimeUnit.MILLISECONDS);
DistributedSamplingPriorityQueue<TransactionEvent> currentEventData = getEventData(APP_NAME);
service.dispatcherTransactionFinished(transactionData, transactionStats);
return currentEventData;
}
Aggregations