use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project cassandra by apache.
the class CassandraMetricsRegistryTest method testJvmMetricsRegistration.
@Test
public void testJvmMetricsRegistration() {
CassandraMetricsRegistry registry = CassandraMetricsRegistry.Metrics;
// Same registration as CassandraDaemon
registry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
registry.register("jvm.gc", new GarbageCollectorMetricSet());
registry.register("jvm.memory", new MemoryUsageGaugeSet());
Collection<String> names = registry.getNames();
// No metric with ".." in name
assertTrue(names.stream().filter(name -> name.contains("..")).count() == 0);
// There should be several metrics within each category
for (String category : new String[] { "jvm.buffers", "jvm.gc", "jvm.memory" }) {
assertTrue(names.stream().filter(name -> name.startsWith(category + '.')).count() > 1);
}
}
use of com.codahale.metrics.jvm.GarbageCollectorMetricSet 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 = JmxReporter.forRegistry(metricRegistry).build();
jmxReporter.start();
metricsAreRegistered = true;
}
use of com.codahale.metrics.jvm.GarbageCollectorMetricSet 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.GarbageCollectorMetricSet in project graylog2-server by Graylog2.
the class MetricRegistryFactory method create.
public static MetricRegistry create() {
MetricRegistry metricRegistry = new MetricRegistry();
metricRegistry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
metricRegistry.register("jvm.cl", new ClassLoadingGaugeSet());
metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet());
metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet());
metricRegistry.register("jvm.threads", new ThreadStatesGaugeSet());
return metricRegistry;
}
use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project mica2 by obiba.
the class MetricsConfiguration method init.
@PostConstruct
public void init() {
log.debug("Registering JVM gauges");
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()));
if (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) {
log.info("Initializing Metrics JMX reporting");
JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build();
jmxReporter.start();
}
}
Aggregations