use of com.newrelic.agent.ConnectionConfigListener in project newrelic-java-agent by newrelic.
the class DatabaseTest method usePreparedStatement.
@Test
public void usePreparedStatement() throws Exception {
final String applicationName = "App";
((ConnectionConfigListener) ServiceFactory.getConfigService()).connected(ServiceFactory.getRPMServiceManager().getRPMService(), new HashMap<String, Object>() {
{
put("transaction_tracer.record_sql", "raw");
}
});
AgentConfig agentConfig = ServiceFactory.getConfigService().getAgentConfig(null);
Assert.assertEquals(SqlObfuscator.RAW_SETTING, agentConfig.getTransactionTracerConfig().getRecordSql());
Assert.assertEquals(SqlObfuscator.RAW_SETTING, agentConfig.getRequestTransactionTracerConfig().getRecordSql());
HttpServlet servlet = new PreparedStatementServlet();
AgentHelper.invokeServlet(servlet, "", applicationName, "/database/test");
AgentHelper.verifyDatastoreMetrics(AgentHelper.getMetrics(), DatastoreVendor.Derby, "test", "select");
}
use of com.newrelic.agent.ConnectionConfigListener in project newrelic-java-agent by newrelic.
the class ConfigServiceTest method badServerData.
@Test
public void badServerData() throws Exception {
Map<String, Object> configMap = AgentConfigFactoryTest.createStagingMap();
createServiceManager(configMap);
MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
ConnectionConfigListener connectionConfigListener = rpmServiceManager.getConnectionConfigListener();
MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
Map<String, Object> data = new HashMap<>();
Map<String, Object> agentData = new HashMap<>();
data.put(AgentConfigFactory.AGENT_CONFIG, agentData);
data.put(AgentConfigImpl.APDEX_T, 0.5d);
data.put(AgentConfigFactory.COLLECT_TRACES, true);
agentData.put(AgentConfigFactory.TRANSACTION_TRACER_PREFIX + TransactionTracerConfigImpl.ENABLED, "bad");
agentData.put(AgentConfigFactory.ERROR_COLLECTOR_PREFIX + ErrorCollectorConfigImpl.ENABLED, !ErrorCollectorConfigImpl.DEFAULT_ENABLED);
connectionConfigListener.connected(rpmService, data);
ConfigService configService = ServiceFactory.getConfigService();
assertFalse(configService.getAgentConfig(null).getTransactionTracerConfig().isEnabled());
assertEquals(ErrorCollectorConfigImpl.DEFAULT_ENABLED, configService.getAgentConfig(null).getErrorCollectorConfig().isEnabled());
}
use of com.newrelic.agent.ConnectionConfigListener in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method requestXStartHeaderRecordApdexMetrics.
@Test
public void requestXStartHeaderRecordApdexMetrics() throws Exception {
MockRPMServiceManager rpmServiceManager = (MockRPMServiceManager) ServiceFactory.getRPMServiceManager();
MockRPMService rpmService = (MockRPMService) rpmServiceManager.getRPMService();
rpmService.setEverConnected(true);
Map<String, Object> data = new HashMap<>();
data.put(AgentConfigImpl.APDEX_T, 6.0d);
ConnectionConfigListener connectionConfigListener = rpmServiceManager.getConnectionConfigListener();
connectionConfigListener.connected(rpmService, data);
MockHttpRequest httpRequest = new MockHttpRequest();
httpRequest.setHeader(QueueTimeTracker.REQUEST_X_START_HEADER, "server1 t=" + (Transaction.getTransaction().getWallClockStartTimeMs() - 24005));
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.getTransaction().getRootTracer().finish(0, null);
StatsEngine statsEngine = ServiceFactory.getStatsService().getStatsEngineForHarvest(APP_NAME);
ApdexStats apdexStats = statsEngine.getApdexStats(MetricName.create(MetricNames.APDEX));
Assert.assertEquals(1, apdexStats.getApdexFrustrating());
apdexStats = statsEngine.getApdexStats(MetricName.create("Apdex/Uri/Unknown"));
Assert.assertEquals(1, apdexStats.getApdexFrustrating());
}
Aggregations