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;
}
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)));
}
}
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;
}
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();
}
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();
}
Aggregations