use of com.newrelic.agent.MockDispatcherTracer in project newrelic-java-agent by newrelic.
the class EventTestHelper method generateTransactionData.
private static TransactionData generateTransactionData(Map<String, Object> userParams, String appName, long durationInMillis) {
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setWebTransaction(true);
MockDispatcherTracer rootTracer = new MockDispatcherTracer();
rootTracer.setDurationInMilliseconds(durationInMillis);
long baseTime = System.nanoTime();
rootTracer.setStartTime(baseTime);
rootTracer.setEndTime(baseTime + TimeUnit.NANOSECONDS.convert(durationInMillis, TimeUnit.MILLISECONDS));
// create a new string instance to verify that the transaction name cache is working
String frontendMetricName = "Frontend/metricname" + System.currentTimeMillis();
final AgentConfig agentConfig = ServiceFactory.getConfigService().getAgentConfig(appName);
return new TransactionDataTestBuilder(appName, agentConfig, rootTracer).setDispatcher(rootTracer).setFrontendMetricName(frontendMetricName).setUserParams(userParams).setIncludeDistributedTracePayload(true).build();
}
use of com.newrelic.agent.MockDispatcherTracer in project newrelic-java-agent by newrelic.
the class ErrorServiceTest method createTransactionData.
private TransactionData createTransactionData(boolean isWebTransaction, int responseStatus, Throwable throwable, boolean expectedError, Map<String, String> requestParams, Map<String, Object> userParams, Map<String, Object> agentParams, Map<String, Object> errorParams, Map<String, Object> intrinsics) {
AgentConfig iAgentConfig = mock(AgentConfig.class);
ErrorCollectorConfig errorCollectorConfig = mock(ErrorCollectorConfig.class);
when(iAgentConfig.getErrorCollectorConfig()).thenReturn(errorCollectorConfig);
MockDispatcher dispatcher = new MockDispatcher();
dispatcher.setWebTransaction(isWebTransaction);
Tracer rootTracer = new MockDispatcherTracer();
String frontendMetricName = isWebTransaction ? "WebTransaction/Uri/dude" : "OtherTransaction/Custom/dude";
return new TransactionDataTestBuilder(APP_NAME, iAgentConfig, rootTracer).setDispatcher(dispatcher).setFrontendMetricName(frontendMetricName).setThrowable(throwable).setExpectedError(expectedError).setRequestUri("/dude").setResponseStatus(responseStatus).setStatusMessage("").setRequestParams(requestParams).setAgentParams(agentParams).setUserParams(userParams).setErrorParams(errorParams).setIntrinsics(intrinsics).build();
}
use of com.newrelic.agent.MockDispatcherTracer in project newrelic-java-agent by newrelic.
the class SlowQueryAggregatorImplTest method createTransactionData.
private TransactionData createTransactionData(String appName, 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));
TransactionTracerConfig ttconf = Mockito.mock(TransactionTracerConfig.class);
when(ttconf.isEnabled()).thenReturn(true);
when(ttconf.getInsertSqlMaxLength()).thenReturn(10 * 1000);
Transaction tx = mock(Transaction.class);
TransactionActivity txa = mock(TransactionActivity.class);
when(txa.getTransaction()).thenReturn(tx);
when(tx.getTransactionActivity()).thenReturn(txa);
when(tx.getTransactionTracerConfig()).thenReturn(ttconf);
List<SlowQueryInfo> tracers = new ArrayList<>(1);
String sql = "select * from TABLE" + Integer.toString(count.incrementAndGet()) + " where Time = 'nigh'";
String obfuscatedSql = sqlObfuscator.obfuscateSql(sql);
SqlTracer sqlTracer = new NoOpTrackingSqlTracer(tx, sql);
SlowQueryInfo slowQueryInfo = new SlowQueryInfo(null, sqlTracer, sql, obfuscatedSql, agentConfig.getSqlTraceConfig());
tracers.add(slowQueryInfo);
SlowQueryListener slowQueryListener = Mockito.mock(SlowQueryListener.class);
org.mockito.Mockito.when(slowQueryListener.getSlowQueries()).thenReturn(tracers);
return new TransactionDataTestBuilder(appName, agentConfig, rootTracer).setTx(tx).setRequestUri(transactionName).setFrontendMetricName(transactionName).setSlowQueryListener(slowQueryListener).build();
}
use of com.newrelic.agent.MockDispatcherTracer in project newrelic-java-agent by newrelic.
the class TransactionTraceBucketTest 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();
}
Aggregations