use of com.newrelic.agent.threads.ThreadStateSampler 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