use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class TransactionTraceBucketTest method slowest.
@Test
public void slowest() throws Exception {
Map<String, Object> configMap = createConfigMap();
Map<String, Object> ttMap = createConfigMap();
ttMap.put(TransactionTracerConfigImpl.TRANSACTION_THRESHOLD, 0.5f);
configMap.put(AgentConfigImpl.TRANSACTION_TRACER, ttMap);
createServiceManager(configMap);
ITransactionSampler transactionSampler = new TransactionTraceSampler();
long durationInMillis = 1000L;
TransactionData td = createTransactionData("/en/betting/Football/*", durationInMillis - 100);
Assert.assertTrue(transactionSampler.noticeTransaction(td));
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertTrue(transactionSampler.noticeTransaction(td));
td = createTransactionData("/en/betting/Football/*", durationInMillis - 200);
Assert.assertFalse(transactionSampler.noticeTransaction(td));
List<TransactionTrace> traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(1, traces.size());
Assert.assertEquals("/en/betting/Football/*", traces.get(0).getRequestUri());
Assert.assertEquals(durationInMillis, traces.get(0).getDuration());
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class TransactionTraceBucketTest method noTraceCount.
@Test
public void noTraceCount() throws Exception {
Map<String, Object> configMap = createConfigMap();
Map<String, Object> ttMap = createConfigMap();
ttMap.put(TransactionTracerConfigImpl.TRANSACTION_THRESHOLD, 0.5f);
ttMap.put(TransactionTracerConfigImpl.TOP_N, 10);
configMap.put(AgentConfigImpl.TRANSACTION_TRACER, ttMap);
createServiceManager(configMap);
ITransactionSampler transactionSampler = new TransactionTraceSampler();
long durationInMillis = 1000L;
TransactionData td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertTrue(transactionSampler.noticeTransaction(td));
List<TransactionTrace> traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(1, traces.size());
Assert.assertEquals("/en/betting/Football/*", traces.get(0).getRequestUri());
Assert.assertEquals(durationInMillis, traces.get(0).getDuration());
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertFalse(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(0, traces.size());
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertFalse(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(0, traces.size());
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertFalse(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(0, traces.size());
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertFalse(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(0, traces.size());
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertFalse(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(0, traces.size());
td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertTrue(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(1, traces.size());
Assert.assertEquals("/en/betting/Football/*", traces.get(0).getRequestUri());
Assert.assertEquals(durationInMillis, traces.get(0).getDuration());
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class TransactionTraceBucketTest method harvest.
@Test
public void harvest() throws Exception {
Map<String, Object> configMap = createConfigMap();
Map<String, Object> ttMap = createConfigMap();
ttMap.put(TransactionTracerConfigImpl.TRANSACTION_THRESHOLD, 0.5f);
configMap.put(AgentConfigImpl.TRANSACTION_TRACER, ttMap);
createServiceManager(configMap);
ITransactionSampler transactionSampler = new TransactionTraceSampler();
long durationInMillis = 1000L;
TransactionData td = createTransactionData("/en/betting/Football/*", durationInMillis);
Assert.assertTrue(transactionSampler.noticeTransaction(td));
List<TransactionTrace> traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(1, traces.size());
Assert.assertEquals("/en/betting/Football/*", traces.get(0).getRequestUri());
Assert.assertEquals(durationInMillis, traces.get(0).getDuration());
td = createTransactionData("/de/betting/Chess/*", durationInMillis + 100L);
Assert.assertTrue(transactionSampler.noticeTransaction(td));
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(1, traces.size());
Assert.assertEquals("/de/betting/Chess/*", traces.get(0).getRequestUri());
Assert.assertEquals(durationInMillis + 100L, traces.get(0).getDuration());
traces = transactionSampler.harvest(APP_NAME);
Assert.assertEquals(0, traces.size());
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class TransactionTraceServiceTest method randomTransactionSampler.
@Test
public void randomTransactionSampler() throws Exception {
Map<String, Object> configMap = createConfigMap();
Map<String, Object> ttConfigMap = new HashMap<>();
configMap.put("transaction_tracer", ttConfigMap);
ttConfigMap.put(TransactionTracerConfigImpl.ENABLED, true);
ttConfigMap.put(TransactionTracerConfigImpl.COLLECT_TRACES, true);
ttConfigMap.put(TransactionTracerConfigImpl.TRANSACTION_THRESHOLD, 1000f);
createServiceManager(configMap);
TransactionTraceService ttService = ServiceFactory.getTransactionTraceService();
TransactionData td = createTransactionData("/en/betting/Baseball/*", APP_NAME, 10L);
ttService.dispatcherTransactionFinished(td, null);
ttService.afterHarvest(APP_NAME);
MockRPMService rpmService = (MockRPMService) ServiceFactory.getRPMServiceManager().getOrCreateRPMService(APP_NAME);
List<TransactionTrace> traces = rpmService.getTraces();
Assert.assertEquals(1, traces.size());
Assert.assertEquals("/en/betting/Baseball/*", traces.get(0).getRequestUri());
Assert.assertEquals(10L, traces.get(0).getDuration());
}
use of com.newrelic.agent.TransactionData in project newrelic-java-agent by newrelic.
the class DistributedTraceServiceImplTest method txnFinished.
@Test
public void txnFinished() {
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
TransactionStats transactionStats = new TransactionStats();
Map<String, Object> intrinsicAttributes = new HashMap<>();
long startTimeInMillis = System.currentTimeMillis();
long responseTimeInNanos = TimeUnit.MILLISECONDS.toNanos(1350);
TransactionData transactionData = createTransactionData(intrinsicAttributes, startTimeInMillis, responseTimeInNanos, null);
distributedTraceService.dispatcherTransactionFinished(transactionData, transactionStats);
SimpleStatsEngine unscopedStats = transactionStats.getUnscopedStats();
String responseTime = MessageFormat.format(MetricNames.DURATION_BY_PARENT_UNKNOWN_ALL, "HTTPS");
String errors = MessageFormat.format(MetricNames.ERRORS_BY_PARENT_UNKNOWN, "HTTPS");
assertEquals(1.35, unscopedStats.getOrCreateResponseTimeStats(responseTime).getTotal(), 0.01f);
assertEquals(1, unscopedStats.getStats(errors).getCallCount());
}
Aggregations