use of com.newrelic.agent.threads.ThreadNameNormalizer in project newrelic-java-agent by newrelic.
the class ProfileTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
Map<String, Object> map = new HashMap<>();
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(map);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
threadNameNormalizer = new ThreadNameNormalizer(agentConfig, threadService);
}
use of com.newrelic.agent.threads.ThreadNameNormalizer in project newrelic-java-agent by newrelic.
the class ThreadService method doStart.
@Override
protected void doStart() throws Exception {
threadNameNormalizer = new ThreadNameNormalizer(ServiceFactory.getConfigService().getDefaultAgentConfig(), this);
AgentConfig config = ServiceFactory.getConfigService().getDefaultAgentConfig();
if (config.getValue("thread_sampler.enabled", Boolean.TRUE)) {
long sampleDelayInSeconds = config.getValue("thread_sampler.sample_delay_in_seconds", 60);
long samplePeriodInSeconds = config.getValue("thread_sampler.sample_period_in_seconds", 60);
if (samplePeriodInSeconds > 0) {
ThreadStateSampler threadStateSampler = new ThreadStateSampler(ManagementFactory.getThreadMXBean(), threadNameNormalizer);
ServiceFactory.getSamplerService().addSampler(threadStateSampler, sampleDelayInSeconds, samplePeriodInSeconds, TimeUnit.SECONDS);
} else {
Agent.LOG.log(Level.FINE, "The thread sampler is disabled because the sample period is {}", samplePeriodInSeconds);
}
} else {
Agent.LOG.log(Level.FINE, "The thread sampler is disabled");
}
}
Aggregations