use of com.newrelic.agent.TransactionDataTestBuilder 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.TransactionDataTestBuilder in project newrelic-java-agent by newrelic.
the class KeyTransactionTraceSamplerTest method createTransactionData.
private TransactionData createTransactionData(String transactionName, long durationInMillis) {
AgentConfig agentConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setWebTransaction(true);
MockDispatcherTracer rootTracer = new MockDispatcherTracer();
rootTracer.setDurationInMilliseconds(durationInMillis);
rootTracer.setStartTime(System.nanoTime());
rootTracer.setEndTime(rootTracer.getStartTime() + TimeUnit.NANOSECONDS.convert(durationInMillis, TimeUnit.MILLISECONDS));
return new TransactionDataTestBuilder(APP_NAME, agentConfig, rootTracer).setDispatcher(dispatcher).setRequestUri(transactionName).setFrontendMetricName(transactionName).build();
}
use of com.newrelic.agent.TransactionDataTestBuilder in project newrelic-java-agent by newrelic.
the class RandomTransactionSamplerTest method createTransactionData.
private TransactionData createTransactionData(String transactionName, long durationInMillis) {
AgentConfig agentConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
MockDispatcher dispatcher = new MockDispatcher();
MockDispatcherTracer rootTracer = new MockDispatcherTracer();
rootTracer.setDurationInMilliseconds(durationInMillis);
rootTracer.setStartTime(System.nanoTime());
rootTracer.setEndTime(rootTracer.getStartTime() + TimeUnit.NANOSECONDS.convert(durationInMillis, TimeUnit.MILLISECONDS));
return new TransactionDataTestBuilder(APP_NAME, agentConfig, rootTracer).setDispatcher(dispatcher).setRequestUri(transactionName).setFrontendMetricName(transactionName).build();
}
use of com.newrelic.agent.TransactionDataTestBuilder in project newrelic-java-agent by newrelic.
the class TransactionTraceServiceTest method createTransactionData.
// if last three arguments are all non-null, created tx will appear to have come from New Relic Synthetics
private TransactionData createTransactionData(String transactionName, String appName, long durationInMillis, String synJobId, String synMonitorId, String synResourceId) {
MockDispatcher dispatcher = new MockDispatcher();
MockDispatcherTracer rootTracer = new MockDispatcherTracer();
rootTracer.setDurationInMilliseconds(durationInMillis);
rootTracer.setStartTime(System.nanoTime());
rootTracer.setEndTime(System.nanoTime() + TimeUnit.NANOSECONDS.convert(durationInMillis, TimeUnit.MILLISECONDS));
AgentConfig agentConfig = ServiceFactory.getConfigService().getDefaultAgentConfig();
return new TransactionDataTestBuilder(appName, agentConfig, rootTracer).setDispatcher(dispatcher).setRequestUri(transactionName).setFrontendMetricName(transactionName).setSynJobId(synJobId).setSynMonitorId(synMonitorId).setSynResourceId(synResourceId).build();
}
use of com.newrelic.agent.TransactionDataTestBuilder in project newrelic-java-agent by newrelic.
the class KeyTransactionProfileTest method generateTransactionData.
private TransactionData generateTransactionData(Multimap<Long, Duration> threadIdToDuration, long startTime, long endTime, String blameMetricName, String appName) {
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setWebTransaction(true);
MockDispatcherTracer rootTracer = new MockDispatcherTracer();
rootTracer.setDurationInMilliseconds(endTime - startTime);
rootTracer.setStartTime(startTime);
rootTracer.setEndTime(endTime);
return new TransactionDataTestBuilder(appName, ServiceFactory.getConfigService().getAgentConfig(appName), rootTracer).setDispatcher(rootTracer).setFrontendMetricName(blameMetricName).setThreadIdToDuration(threadIdToDuration).build();
}
Aggregations