Search in sources :

Example 6 with MockDispatcher

use of com.newrelic.agent.MockDispatcher 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 7 with MockDispatcher

use of com.newrelic.agent.MockDispatcher 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 8 with MockDispatcher

use of com.newrelic.agent.MockDispatcher 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 9 with MockDispatcher

use of com.newrelic.agent.MockDispatcher 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)

Example 10 with MockDispatcher

use of com.newrelic.agent.MockDispatcher in project newrelic-java-agent by newrelic.

the class ProfileTest method generateTransactionData.

private TransactionData generateTransactionData(Multimap<Long, Duration> threadIdToDuration, long startTime, long endTime, String appName) {
    MockDispatcher dispatcher = new MockDispatcher();
    dispatcher.setWebTransaction(true);
    MockDispatcherTracer rootTracer = new MockDispatcherTracer();
    rootTracer.setDurationInMilliseconds(endTime - startTime);
    rootTracer.setStartTime(startTime);
    rootTracer.setEndTime(endTime);
    AgentConfig agentConfig = ServiceFactory.getConfigService().getAgentConfig(appName);
    return new TransactionDataTestBuilder(appName, agentConfig, rootTracer).setDispatcher(rootTracer).setFrontendMetricName("keyTransaction").setThreadIdToDuration(threadIdToDuration).build();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) MockDispatcherTracer(com.newrelic.agent.MockDispatcherTracer) MockDispatcher(com.newrelic.agent.MockDispatcher) TransactionDataTestBuilder(com.newrelic.agent.TransactionDataTestBuilder)

Aggregations

MockDispatcher (com.newrelic.agent.MockDispatcher)17 MockDispatcherTracer (com.newrelic.agent.MockDispatcherTracer)11 TransactionDataTestBuilder (com.newrelic.agent.TransactionDataTestBuilder)10 AgentConfig (com.newrelic.agent.config.AgentConfig)9 Transaction (com.newrelic.agent.Transaction)8 Tracer (com.newrelic.agent.tracers.Tracer)7 ClassMethodSignature (com.newrelic.agent.tracers.ClassMethodSignature)6 OtherRootTracer (com.newrelic.agent.tracers.OtherRootTracer)6 TransactionData (com.newrelic.agent.TransactionData)5 DefaultTracer (com.newrelic.agent.tracers.DefaultTracer)5 Test (org.junit.Test)5 SqlTraceConfig (com.newrelic.agent.config.SqlTraceConfig)4 HashMap (java.util.HashMap)4 TransactionActivity (com.newrelic.agent.TransactionActivity)2 ServerProp (com.newrelic.agent.config.ServerProp)2 TransactionTracerConfig (com.newrelic.agent.config.TransactionTracerConfig)2 JSONObject (org.json.simple.JSONObject)2 ErrorCollectorConfig (com.newrelic.agent.config.ErrorCollectorConfig)1 NoOpTrackingSqlTracer (com.newrelic.agent.instrumentation.sql.NoOpTrackingSqlTracer)1 MethodExitTracer (com.newrelic.agent.tracers.MethodExitTracer)1