Search in sources :

Example 1 with DatabaseService

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();
    }
}
Also used : ConnectionFactory(com.newrelic.agent.bridge.datastore.ConnectionFactory) DatabaseVendor(com.newrelic.agent.bridge.datastore.DatabaseVendor) Connection(java.sql.Connection) ExplainPlanExecutor(com.newrelic.agent.database.ExplainPlanExecutor) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) DatabaseService(com.newrelic.agent.database.DatabaseService) IOException(java.io.IOException)

Example 2 with DatabaseService

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));
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) UtilizationService(com.newrelic.agent.utilization.UtilizationService) RPMConnectionService(com.newrelic.agent.rpm.RPMConnectionService) StatsService(com.newrelic.agent.stats.StatsService) AttributesService(com.newrelic.agent.attributes.AttributesService) DatabaseService(com.newrelic.agent.database.DatabaseService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) RPMConnectionServiceImpl(com.newrelic.agent.rpm.RPMConnectionServiceImpl) SpanEventsServiceImpl(com.newrelic.agent.service.analytics.SpanEventsServiceImpl) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) ProfilerService(com.newrelic.agent.profile.ProfilerService)

Example 3 with DatabaseService

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();
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) DatabaseService(com.newrelic.agent.database.DatabaseService) MockRPMService(com.newrelic.agent.MockRPMService) CommandParser(com.newrelic.agent.commands.CommandParser)

Example 4 with DatabaseService

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();
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) DatabaseService(com.newrelic.agent.database.DatabaseService) MockRPMService(com.newrelic.agent.MockRPMService) CommandParser(com.newrelic.agent.commands.CommandParser)

Example 5 with DatabaseService

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);
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) DatabaseService(com.newrelic.agent.database.DatabaseService)

Aggregations

DatabaseService (com.newrelic.agent.database.DatabaseService)15 AttributesService (com.newrelic.agent.attributes.AttributesService)10 ConfigService (com.newrelic.agent.config.ConfigService)10 MockServiceManager (com.newrelic.agent.MockServiceManager)9 TransactionService (com.newrelic.agent.TransactionService)8 HarvestService (com.newrelic.agent.HarvestService)7 MockHarvestService (com.newrelic.agent.MockHarvestService)7 MockRPMService (com.newrelic.agent.MockRPMService)7 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)7 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)7 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)7 AgentConfig (com.newrelic.agent.config.AgentConfig)6 ThreadService (com.newrelic.agent.ThreadService)5 CommandParser (com.newrelic.agent.commands.CommandParser)5 StatsService (com.newrelic.agent.stats.StatsService)5 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)5 MockCoreService (com.newrelic.agent.MockCoreService)4 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)4 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)4 CircuitBreakerService (com.newrelic.agent.circuitbreaker.CircuitBreakerService)3