Search in sources :

Example 26 with ThreadService

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

the class ServiceManagerImpl method getServicesConfiguration.

@Override
public Map<String, Map<String, Object>> getServicesConfiguration() {
    Map<String, Map<String, Object>> config = new HashMap<>();
    Map<String, Object> serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", transactionService.isEnabled());
    config.put("TransactionService", serviceInfo);
    serviceInfo = new HashMap<>();
    config.put("TransactionTraceService", serviceInfo);
    serviceInfo.put("enabled", transactionTraceService.isEnabled());
    serviceInfo = new HashMap<>();
    config.put("TransactionEventsService", serviceInfo);
    serviceInfo.put("enabled", transactionEventsService.isEnabled());
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", profilerService.isEnabled());
    config.put("ProfilerService", serviceInfo);
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", tracerService.isEnabled());
    config.put("TracerService", serviceInfo);
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", commandParser.isEnabled());
    config.put("CommandParser", serviceInfo);
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", jfrService.isEnabled());
    config.put("JfrService", serviceInfo);
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", jmxService.isEnabled());
    config.put("JmxService", serviceInfo);
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", threadService.isEnabled());
    config.put("ThreadService", serviceInfo);
    serviceInfo = new HashMap<>();
    serviceInfo.put("enabled", deadlockDetectorService.isEnabled());
    config.put("DeadlockService", serviceInfo);
    for (Service service : services.values()) {
        serviceInfo = new HashMap<>();
        serviceInfo.put("enabled", service.isEnabled());
        config.put(service.getClass().getSimpleName(), serviceInfo);
    }
    return config;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) JarCollectorService(com.newrelic.agent.service.module.JarCollectorService) SamplerService(com.newrelic.agent.samplers.SamplerService) SpanEventsService(com.newrelic.agent.service.analytics.SpanEventsService) GCService(com.newrelic.agent.GCService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) LogSenderService(com.newrelic.agent.service.logging.LogSenderService) TracerService(com.newrelic.agent.TracerService) UtilizationService(com.newrelic.agent.utilization.UtilizationService) RPMConnectionService(com.newrelic.agent.rpm.RPMConnectionService) DeadlockDetectorService(com.newrelic.agent.deadlock.DeadlockDetectorService) ExtensionService(com.newrelic.agent.extension.ExtensionService) TransactionService(com.newrelic.agent.TransactionService) CacheService(com.newrelic.agent.cache.CacheService) SourceLanguageService(com.newrelic.agent.language.SourceLanguageService) CoreService(com.newrelic.agent.core.CoreService) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) CircuitBreakerService(com.newrelic.agent.circuitbreaker.CircuitBreakerService) InsightsService(com.newrelic.agent.service.analytics.InsightsService) JmxService(com.newrelic.agent.jmx.JmxService) AttributesService(com.newrelic.agent.attributes.AttributesService) ThreadService(com.newrelic.agent.ThreadService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) ExpirationService(com.newrelic.agent.ExpirationService) CPUSamplerService(com.newrelic.agent.samplers.CPUSamplerService) ExecutorService(java.util.concurrent.ExecutorService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceService(com.newrelic.agent.tracing.DistributedTraceService) ProfilerService(com.newrelic.agent.profile.ProfilerService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) NormalizationService(com.newrelic.agent.normalization.NormalizationService) BrowserService(com.newrelic.agent.browser.BrowserService) HarvestService(com.newrelic.agent.HarvestService) DatabaseService(com.newrelic.agent.database.DatabaseService) RemoteInstrumentationService(com.newrelic.agent.reinstrument.RemoteInstrumentationService) ConfigService(com.newrelic.agent.config.ConfigService) ClassTransformerService(com.newrelic.agent.instrumentation.ClassTransformerService) JfrService(com.newrelic.agent.jfr.JfrService) NoopSamplerService(com.newrelic.agent.samplers.NoopSamplerService) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 27 with ThreadService

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

the class Profile method end.

/**
 * Subclasses may override.
 */
@Override
public void end() {
    endTimeMillis = System.currentTimeMillis();
    Map<Long, Long> endThreadCpuTimes = getThreadCpuTimes();
    ThreadService threadService = ServiceFactory.getThreadService();
    final Set<Long> agentThreadIds = threadService.getAgentThreadIds();
    for (Entry<Long, Long> entry : endThreadCpuTimes.entrySet()) {
        Long startTime = startThreadCpuTimes.get(entry.getKey());
        if (startTime == null) {
            startTime = 0l;
        }
        long cpuTime = TimeUnit.MILLISECONDS.convert(entry.getValue() - startTime, TimeUnit.NANOSECONDS);
        ProfileTree tree;
        if (agentThreadIds.contains(entry.getKey())) {
            tree = getProfileTree(ThreadType.BasicThreadType.AGENT);
        } else {
            tree = getProfileTree(ThreadType.BasicThreadType.OTHER);
        }
        tree.incrementCpuTime(cpuTime);
    }
    int stackCount = getCallSiteCount();
    String msg = MessageFormat.format("Profile size is {0} stack elements", stackCount);
    Agent.LOG.info(msg);
    if (stackCount > MAX_STACK_SIZE) {
        Agent.LOG.info(MessageFormat.format("Trimmed profile size by {0} stack elements", trim(stackCount - MAX_STACK_SIZE, stackCount)));
    }
}
Also used : ThreadService(com.newrelic.agent.ThreadService)

Example 28 with ThreadService

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

the class DatabaseServiceTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> configMap) throws Exception {
    AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
    serviceManager.setConfigService(configService);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    DatabaseService dbService = new DatabaseService();
    serviceManager.setDatabaseService(dbService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setEverConnected(true);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
    configService.start();
    serviceManager.start();
    sqlTraceService.start();
    return serviceManager;
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockHarvestService(com.newrelic.agent.MockHarvestService) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 29 with ThreadService

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

the class GeneratorVisitTracerFactoryTest method createServiceManager.

private static void createServiceManager(Map<String, Object> map) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
    configService.start();
    serviceManager.setNormalizationService(new NormalizationServiceImpl());
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    statsService.start();
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

Example 30 with ThreadService

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

the class RumParserTest method createServiceManager.

private static void createServiceManager(Map<String, Object> map) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    HarvestService harvestService = new MockHarvestService();
    serviceManager.setHarvestService(harvestService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
    serviceManager.setSqlTraceService(sqlTraceService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
    configService.start();
    serviceManager.setNormalizationService(new NormalizationServiceImpl());
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    statsService.start();
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

Aggregations

ThreadService (com.newrelic.agent.ThreadService)37 MockServiceManager (com.newrelic.agent.MockServiceManager)34 ConfigService (com.newrelic.agent.config.ConfigService)32 TransactionService (com.newrelic.agent.TransactionService)30 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)24 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)23 HarvestService (com.newrelic.agent.HarvestService)21 MockHarvestService (com.newrelic.agent.MockHarvestService)18 AgentConfig (com.newrelic.agent.config.AgentConfig)18 MockCoreService (com.newrelic.agent.MockCoreService)17 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)16 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)16 MockRPMService (com.newrelic.agent.MockRPMService)15 AttributesService (com.newrelic.agent.attributes.AttributesService)13 StatsService (com.newrelic.agent.stats.StatsService)13 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)13 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)12 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)8 HashMap (java.util.HashMap)8 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)7