use of com.codahale.metrics.jvm.ThreadStatesGaugeSet in project dropwizard by dropwizard.
the class Bootstrap method registerMetrics.
/**
* Registers the JVM metrics to the metric registry and start to report
* the registry metrics via JMX.
*/
public void registerMetrics() {
if (metricsAreRegistered) {
return;
}
getMetricRegistry().register("jvm.attribute", new JvmAttributeGaugeSet());
getMetricRegistry().register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
getMetricRegistry().register("jvm.classloader", new ClassLoadingGaugeSet());
getMetricRegistry().register("jvm.filedescriptor", new FileDescriptorRatioGauge());
getMetricRegistry().register("jvm.gc", new GarbageCollectorMetricSet());
getMetricRegistry().register("jvm.memory", new MemoryUsageGaugeSet());
getMetricRegistry().register("jvm.threads", new ThreadStatesGaugeSet());
JmxReporter.forRegistry(metricRegistry).build().start();
metricsAreRegistered = true;
}
use of com.codahale.metrics.jvm.ThreadStatesGaugeSet in project chassis by Kixeye.
the class ChassisConfiguration method metricRegistry.
/**
* Initializes the metrics registry
*
* @return metric registry bean
*/
@Bean
public MetricRegistry metricRegistry() {
final MetricRegistry bean = new MetricRegistry();
// add JVM metrics
bean.register("jvm.gc", new GarbageCollectorMetricSet());
bean.register("jvm.memory", new MemoryUsageGaugeSet());
bean.register("jvm.thread-states", new ThreadStatesGaugeSet());
bean.register("jvm.fd", new FileDescriptorRatioGauge());
bean.register("jvm.load-average", new Gauge<Double>() {
private OperatingSystemMXBean mxBean = ManagementFactory.getOperatingSystemMXBean();
public Double getValue() {
try {
return mxBean.getSystemLoadAverage();
} catch (Exception e) {
// not supported
return -1d;
}
}
});
// add Logback metrics
final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
final InstrumentedAppender appender = new InstrumentedAppender(bean);
appender.setContext(root.getLoggerContext());
appender.start();
root.addAppender(appender);
return bean;
}
use of com.codahale.metrics.jvm.ThreadStatesGaugeSet in project cas by apereo.
the class CasMetricsConfiguration method metrics.
/**
* Metric registry metric registry.
*
* @return the metric registry
*/
@RefreshScope
@Bean
public MetricRegistry metrics() {
final MetricRegistry metrics = new MetricRegistry();
metrics.register("jvm.gc", new GarbageCollectorMetricSet());
metrics.register("jvm.memory", new MemoryUsageGaugeSet());
metrics.register("thread-states", new ThreadStatesGaugeSet());
metrics.register("jvm.fd.usage", new FileDescriptorRatioGauge());
return metrics;
}
use of com.codahale.metrics.jvm.ThreadStatesGaugeSet in project ninja by ninjaframework.
the class MetricsServiceImpl method start.
@Start(order = 10)
@Override
public void start() {
String applicationName = ninjaProps.getWithDefault(NinjaConstant.applicationName, "Ninja");
/*
* Register optional metrics
*/
if (ninjaProps.getBooleanWithDefault("metrics.jvm.enabled", false)) {
registerAll("jvm.gc", new GarbageCollectorMetricSet());
registerAll("jvm.memory", new MemoryUsageGaugeSet());
registerAll("jvm.threads", new ThreadStatesGaugeSet());
registerAll("jvm.classes", new ClassLoadingGaugeSet());
log.debug("Registered JVM-Metrics integration");
}
if (ninjaProps.getBooleanWithDefault("metrics.logback.enabled", false)) {
final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
final ch.qos.logback.classic.Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
final InstrumentedAppender appender = new InstrumentedAppender(metricRegistry);
appender.setContext(root.getLoggerContext());
appender.start();
root.addAppender(appender);
log.debug("Registered Logback-Metrics integration");
}
/*
* MBeans for VisualVM, JConsole, or JMX
*/
if (ninjaProps.getBooleanWithDefault("metrics.mbeans.enabled", true)) {
JmxReporter reporter = JmxReporter.forRegistry(metricRegistry).inDomain(applicationName).build();
reporter.start();
reporters.add(reporter);
log.debug("Started Ninja Metrics MBeans reporter");
}
log.info("Ninja Metrics is ready for collection.");
}
use of com.codahale.metrics.jvm.ThreadStatesGaugeSet in project pinpoint by naver.
the class CollectorMetric method initRegistry.
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());
}
}
}
Aggregations