Search in sources :

Example 6 with TransactionDataTestBuilder

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());
}
Also used : TransactionActivityInitiator(com.newrelic.agent.tracers.TransactionActivityInitiator) TransactionStats(com.newrelic.agent.stats.TransactionStats) MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) EventTestHelper.generateTransactionData(com.newrelic.agent.service.analytics.EventTestHelper.generateTransactionData) TransactionData(com.newrelic.agent.TransactionData) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder) OtherRootTracer(com.newrelic.agent.tracers.OtherRootTracer) Test(org.junit.Test)

Example 7 with TransactionDataTestBuilder

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();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder)

Example 8 with TransactionDataTestBuilder

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();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder)

Example 9 with TransactionDataTestBuilder

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();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder)

Example 10 with TransactionDataTestBuilder

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();
}
Also used : MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder)

Aggregations

TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)20 MockDispatcherTracer (com.newrelic.agent.MockDispatcherTracer)11 MockDispatcher (com.newrelic.agent.MockDispatcher)10 TransactionData (com.newrelic.agent.TransactionData)10 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)10 Tracer (com.newrelic.agent.tracers.Tracer)10 Test (org.junit.Test)10 AgentConfig (com.newrelic.agent.config.AgentConfig)9 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)9 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)9 MethodExitTracer (com.newrelic.agent.tracers.MethodExitTracer)9 JSONArray (org.json.simple.JSONArray)9 JSONObject (org.json.simple.JSONObject)9 JSONParser (org.json.simple.parser.JSONParser)9 HashMap (java.util.HashMap)8 ImmutableMap (com.google.common.collect.ImmutableMap)7 Map (java.util.Map)7 Transaction (com.newrelic.agent.Transaction)2 TransactionActivity (com.newrelic.agent.TransactionActivity)1 ErrorCollectorConfig (com.newrelic.agent.config.ErrorCollectorConfig)1