use of com.newrelic.agent.database.DatabaseService in project newrelic-java-agent by newrelic.
the class TransactionTrace method runExplainPlans.
private void runExplainPlans() {
if (!sqlTracers.isEmpty()) {
DatabaseService dbService = ServiceFactory.getDatabaseService();
for (Entry<ConnectionFactory, List<ExplainPlanExecutor>> entry : sqlTracers.entrySet()) {
Agent.LOG.finer(MessageFormat.format("Running {0} explain plan(s)", entry.getValue().size()));
Connection connection = null;
try {
connection = entry.getKey().getConnection();
DatabaseVendor vendor = entry.getKey().getDatabaseVendor();
for (ExplainPlanExecutor explainExecutor : entry.getValue()) {
if (explainExecutor != null) {
explainExecutor.runExplainPlan(dbService, connection, vendor);
}
}
} catch (Throwable t) {
String msg = MessageFormat.format("An error occurred executing an explain plan: {0}", t.toString());
if (Agent.LOG.isLoggable(Level.FINER)) {
Agent.LOG.log(Level.FINER, msg, t);
} else {
Agent.LOG.fine(msg);
}
} finally {
if (connection != null) {
try {
connection.close();
} catch (Exception e) {
Agent.LOG.log(Level.FINER, "Unable to close connection", e);
}
}
}
}
sqlTracers.clear();
}
}
use of com.newrelic.agent.database.DatabaseService in project newrelic-java-agent by newrelic.
the class RPMServiceTest method createServiceManager.
private void createServiceManager(AgentConfig config, Map<String, Object> localSettings) {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(config, localSettings);
serviceManager.setConfigService(configService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
RPMConnectionService rpmConnectionService = new RPMConnectionServiceImpl();
serviceManager.setRPMConnectionService(rpmConnectionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
UtilizationService utilService = new UtilizationService();
serviceManager.setUtilizationService(utilService);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
when(transactionDataToDistributedTraceIntrinsics.buildDistributedTracingIntrinsics(any(TransactionData.class), anyBoolean())).thenReturn(Collections.<String, Object>emptyMap());
TransactionEventsService transactionEventsService = new TransactionEventsService(transactionDataToDistributedTraceIntrinsics);
serviceManager.setTransactionEventsService(transactionEventsService);
serviceManager.setSpansEventService(mock(SpanEventsServiceImpl.class));
}
use of com.newrelic.agent.database.DatabaseService in project newrelic-java-agent by newrelic.
the class TransactionTraceServiceTest method createServiceManager.
private void createServiceManager(Map<String, Object> configMap) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
serviceManager.setConfigService(configService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setIsConnected(true);
rpmServiceManager.setRPMService(rpmService);
CommandParser commandParser = new CommandParser();
serviceManager.setCommandParser(commandParser);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
TransactionTraceService ttService = new TransactionTraceService();
serviceManager.setTransactionTraceService(ttService);
ttService.start();
}
use of com.newrelic.agent.database.DatabaseService in project newrelic-java-agent by newrelic.
the class KeyTransactionTraceSamplerTest method createServiceManager.
private void createServiceManager(Map<String, Object> configMap) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
serviceManager.setConfigService(configService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setIsConnected(true);
rpmServiceManager.setRPMService(rpmService);
CommandParser commandParser = new CommandParser();
serviceManager.setCommandParser(commandParser);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
TransactionTraceService ttService = new TransactionTraceService();
serviceManager.setTransactionTraceService(ttService);
ttService.start();
}
use of com.newrelic.agent.database.DatabaseService in project newrelic-java-agent by newrelic.
the class RandomTransactionSamplerTest method createServiceManager.
private void createServiceManager() throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
Map<String, Object> configMap = createConfigMap();
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
serviceManager.setConfigService(configService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
TransactionTraceService ttService = new TransactionTraceService();
serviceManager.setTransactionTraceService(ttService);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
}
Aggregations