本文整理匯總了Java中com.codahale.metrics.jvm.ThreadStatesGaugeSet類的典型用法代碼示例。如果您正苦於以下問題:Java ThreadStatesGaugeSet類的具體用法?Java ThreadStatesGaugeSet怎麽用?Java ThreadStatesGaugeSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ThreadStatesGaugeSet類屬於com.codahale.metrics.jvm包,在下文中一共展示了ThreadStatesGaugeSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMetricsHandler
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
private ServletContextHandler getMetricsHandler() {
MetricRegistry registry = Metrics.getRegistry();
HealthCheckRegistry healthCheckRegistry = Metrics.getHealthCheckRegistry();
healthCheckRegistry.register("rotation", new Rotation(configuration.getRotationStatusFilePath()));
registry.registerAll(new GarbageCollectorMetricSet());
registry.registerAll(new MemoryUsageGaugeSet());
registry.registerAll(new ThreadStatesGaugeSet());
registry.registerAll(new JvmAttributeGaugeSet());
ServletContextHandler servletContextHandler = new ServletContextHandler();
servletContextHandler.setContextPath("/__metrics");
servletContextHandler.setAttribute(MetricsServlet.class.getCanonicalName() + ".registry", registry);
servletContextHandler.setAttribute(HealthCheckServlet.class.getCanonicalName() + ".registry", healthCheckRegistry);
servletContextHandler.addServlet(new ServletHolder(new AdminServlet()), "/*");
return servletContextHandler;
}
示例2: init
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
@PostConstruct
public void init() {
/*
* consoleReporter = ConsoleReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS)
* .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); consoleReporter.start(1, TimeUnit.SECONDS);
*/
GarbageCollectorMetricSet gc = new GarbageCollectorMetricSet();
// FileDescriptorRatioGauge fd = new FileDescriptorRatioGauge();
MemoryUsageGaugeSet mu = new MemoryUsageGaugeSet();
// ThreadDeadlockDetector td = new ThreadDeadlockDetector();
// ThreadDump t = new ThreadDump();
ThreadStatesGaugeSet ts = new ThreadStatesGaugeSet();
metricRegistry.register("GarbageCollector", gc);
// registry.register(FileDescriptorRatioGauge.class.getName(), fd);
metricRegistry.register("MemoryUsage", mu);
// registry.register(ThreadDeadlockDetector.class.getName(), td);
// registry.registerAll(t);
metricRegistry.register("ThreadStates", ts);
healthCheckRegistry.register("threadDeadlock",
new ThreadDeadlockHealthCheck());
}
示例3: build
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
public CloudWatchReporter build() {
if (withJvmMetrics) {
metricRegistry.register("jvm.uptime", (Gauge<Long>) () -> ManagementFactory.getRuntimeMXBean().getUptime());
metricRegistry.register("jvm.current_time", (Gauge<Long>) clock::getTime);
metricRegistry.register("jvm.classes", new ClassLoadingGaugeSet());
metricRegistry.register("jvm.fd_usage", new FileDescriptorRatioGauge());
metricRegistry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
}
cwRateUnit = toStandardUnit(rateUnit);
cwDurationUnit = toStandardUnit(durationUnit);
return new CloudWatchReporter(this);
}
開發者ID:azagniotov,項目名稱:codahale-aggregated-metrics-cloudwatch-reporter,代碼行數:19,代碼來源:CloudWatchReporter.java
示例4: enableJvm
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
public static void enableJvm() {
if (bEnableJvm)
return;
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS,
new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
jmxReporter.start();
bEnableJvm = true;
}
示例5: onStartup
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS,
new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry);
FilterRegistration.Dynamic metricsFilter =
servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter());
metricsFilter.addMappingForUrlPatterns(
EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC), true,
"/*");
metricsFilter.setAsyncSupported(true);
}
示例6: start
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
public void start() {
setMetricsReporter(metricsGroupName);
final String jvmMetricsName = metricsGroupName + "-JVM";
setMetricsReporter(jvmMetricsName);
if(!inited) {
metricRegistry.register(MetricRegistry.name(jvmMetricsName, "MEMORY"), new MemoryUsageGaugeSet());
metricRegistry.register(MetricRegistry.name(jvmMetricsName, "FILE"), new FileDescriptorRatioGauge());
metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet());
metricRegistry.register(MetricRegistry.name(jvmMetricsName, "THREAD"), new ThreadStatesGaugeSet());
metricRegistry.register(MetricRegistry.name(jvmMetricsName, "LOG"), new LogEventGaugeSet());
jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain("Tajo")
.createsObjectNamesWith(new TajoJMXObjectNameFactory()).build();
jmxReporter.start();
}
inited = true;
}
示例7: addJvmMetrics
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
/**
* Add metrics JVM gauges.
*/
private void addJvmMetrics() {
if (getB("jvm.gcstats", false)) {
ooMetricsRegistry.registerAll(new GarbageCollectorMetricSet());
}
if (getB("jvm.memory", false)) {
ooMetricsRegistry.registerAll(new MemoryUsageGaugeSet());
}
if (getB("jvm.threadstate", false)) {
ooMetricsRegistry.registerAll(new ThreadStatesGaugeSet());
}
if (getB("jvm.filedescriptor", false)) {
ooMetricsRegistry.register("openfd.ratio", new FileDescriptorRatioGauge());
}
}
示例8: initRegistry
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
private void initRegistry() {
// add JVM statistics
metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
metricRegistry.register("jvm.vm", new JvmAttributeGaugeSet());
metricRegistry.register("jvm.garbage-collectors", new GarbageCollectorMetricSet());
metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
if (hBaseAsyncOperationMetrics != null) {
Map<String, Metric> metrics = hBaseAsyncOperationMetrics.getMetrics();
for (Map.Entry<String, Metric> metric : metrics.entrySet()) {
metricRegistry.register(metric.getKey(), metric.getValue());
}
}
}
示例9: configureJvmMetrics
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
private static void configureJvmMetrics(MetricRegistry registry) {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
registry.register("jvm.buffer-pool", new BufferPoolMetricSet(mBeanServer));
registry.register("jvm.class-loading", new ClassLoadingGaugeSet());
registry.register("jvm.file-descriptor-ratio", new FileDescriptorRatioGauge());
registry.register("jvm.gc", new GarbageCollectorMetricSet());
registry.register("jvm.memory", new MemoryUsageGaugeSet());
registry.register("jvm.threads", new ThreadStatesGaugeSet());
}
示例10: main
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
public static void main(String[] args) throws IOException, InterruptedException {
ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics).convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS).build();
metrics.register("jvm.mem", new MemoryUsageGaugeSet());
metrics.register("jvm.gc", new GarbageCollectorMetricSet() );
metrics.register("jvm.threads", new ThreadStatesGaugeSet() );
reporter.start(30, TimeUnit.SECONDS);
TimeUnit.SECONDS.sleep(500);
}
示例11: init
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
@PostConstruct
public void init() {
log.debug("Registering JVM gauges");
metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
if (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
log.info("Initializing Metrics JMX reporting");
JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
jmxReporter.start();
}
}
示例12: reportJvmMetrics
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
/**
* Adds JVM MetricSets to this engine. By default JVM metrics are not placed in the Registry
*/
public CodahaleMetricsEngine reportJvmMetrics() {
// add JVM metrics
if (!jvmMetricsAdded) {
metricsCollector.registerAll("JVM-gc", new GarbageCollectorMetricSet());
metricsCollector
.registerAll("JVM-buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
metricsCollector.registerAll("JVM-memory", new MemoryUsageGaugeSet());
metricsCollector.registerAll("JVM-threads", new ThreadStatesGaugeSet());
jvmMetricsAdded = true;
}
return this;
}
示例13: MetricPaasService
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
public MetricPaasService() throws IOException {
super();
metrics.register("Heap", new MemoryUsageGaugeSet());
metrics.register("GC", new GarbageCollectorMetricSet());
metrics.register("Thread", new ThreadStatesGaugeSet());
metrics.register("CPU", new CpuUsageGaugeSet());
JmxReporter reporter = JmxReporter.forRegistry(metrics).build();
reporter.start();
}
示例14: init
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
@PostConstruct
public void init() {
log.debug("Registering JVM gauges");
metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet());
metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet());
metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge());
metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
if (hikariDataSource != null) {
log.debug("Monitoring the datasource");
hikariDataSource.setMetricRegistry(metricRegistry);
}
if (jHipsterProperties.getMetrics().getJmx().isEnabled()) {
log.debug("Initializing Metrics JMX reporting");
JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build();
jmxReporter.start();
}
if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
log.info("Initializing Metrics Log reporting");
final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
.outputTo(LoggerFactory.getLogger("metrics"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS);
}
}
示例15: configureReporters
import com.codahale.metrics.jvm.ThreadStatesGaugeSet; //導入依賴的package包/類
@Override
public void configureReporters(MetricRegistry metricRegistry) {
metricRegistry.addListener(metricsListener);
metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet());
metricRegistry.register("jvm.fd.usage", new FileDescriptorRatioGauge());
if(environment.acceptsProfiles(AmqpUtils.PROFILE)) {
final String applicationId = AppInfo.getApplicationName();
AmqpUtils.ExchangeFactory exchangeFactory = new AmqpUtils.ExchangeFactory();
exchangeFactory.setExchangeName(exchange);
AmqpReporter amqpReporter = AmqpReporter.forRegistry(metricRegistry)
.connectionFactoryProvider(connectionFactoryProvider)
.exchangeName(exchange)
.routingKey(applicationId)
.exchangeFactory(exchangeFactory)
.build();
amqpReporter.start(reportPeriod, TimeUnit.SECONDS);
LOG.info("AmqpReporter enabled: applicationId: {} reportPeriod: {} seconds, exchange: {}",
applicationId, reportPeriod, exchange);
} else {
//sample configuration for metrics reported
// https://dropwizard.github.io/metrics/3.1.0/manual/core/#man-core-reporters-console
final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry)
.outputTo(LoggerFactory.getLogger("com.codeabovelab.dm.metrics"))
.convertRatesTo(TimeUnit.SECONDS)
.convertDurationsTo(TimeUnit.MILLISECONDS)
.build();
reporter.start(reportPeriod, TimeUnit.SECONDS);
}
}