Search in sources :

Example 6 with GarbageCollectorMetricSet

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);
    }
}
Also used : BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) TimeUnit(java.util.concurrent.TimeUnit) BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) EstimatedHistogram(org.apache.cassandra.utils.EstimatedHistogram) Collection(java.util.Collection) Timer(com.codahale.metrics.Timer) MetricName(org.apache.cassandra.metrics.CassandraMetricsRegistry.MetricName) Test(org.junit.Test) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) ManagementFactory(java.lang.management.ManagementFactory) Assert(org.junit.Assert) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) Test(org.junit.Test)

Example 7 with GarbageCollectorMetricSet

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;
}
Also used : BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) JvmAttributeGaugeSet(com.codahale.metrics.jvm.JvmAttributeGaugeSet) FileDescriptorRatioGauge(com.codahale.metrics.jvm.FileDescriptorRatioGauge) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) ClassLoadingGaugeSet(com.codahale.metrics.jvm.ClassLoadingGaugeSet) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet)

Example 8 with GarbageCollectorMetricSet

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;
}
Also used : InstrumentedAppender(com.codahale.metrics.logback.InstrumentedAppender) FileDescriptorRatioGauge(com.codahale.metrics.jvm.FileDescriptorRatioGauge) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) Logger(ch.qos.logback.classic.Logger) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) LoggerContext(ch.qos.logback.classic.LoggerContext) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean) Bean(org.springframework.context.annotation.Bean)

Example 9 with GarbageCollectorMetricSet

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;
}
Also used : BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) ClassLoadingGaugeSet(com.codahale.metrics.jvm.ClassLoadingGaugeSet) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet)

Example 10 with GarbageCollectorMetricSet

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();
    }
}
Also used : BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) FileDescriptorRatioGauge(com.codahale.metrics.jvm.FileDescriptorRatioGauge) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) JmxReporter(com.codahale.metrics.JmxReporter) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) PostConstruct(javax.annotation.PostConstruct)

Aggregations

GarbageCollectorMetricSet (com.codahale.metrics.jvm.GarbageCollectorMetricSet)23 MemoryUsageGaugeSet (com.codahale.metrics.jvm.MemoryUsageGaugeSet)23 ThreadStatesGaugeSet (com.codahale.metrics.jvm.ThreadStatesGaugeSet)17 FileDescriptorRatioGauge (com.codahale.metrics.jvm.FileDescriptorRatioGauge)11 BufferPoolMetricSet (com.codahale.metrics.jvm.BufferPoolMetricSet)10 MetricRegistry (com.codahale.metrics.MetricRegistry)8 ClassLoadingGaugeSet (com.codahale.metrics.jvm.ClassLoadingGaugeSet)8 Bean (org.springframework.context.annotation.Bean)4 Map (java.util.Map)3 PostConstruct (javax.annotation.PostConstruct)3 LoggerContext (ch.qos.logback.classic.LoggerContext)2 JmxReporter (com.codahale.metrics.JmxReporter)2 MetricSet (com.codahale.metrics.MetricSet)2 InstrumentedAppender (com.codahale.metrics.logback.InstrumentedAppender)2 IOException (java.io.IOException)2 Logger (ch.qos.logback.classic.Logger)1 JvmAttributeGaugeSet (com.codahale.metrics.JvmAttributeGaugeSet)1 Metric (com.codahale.metrics.Metric)1 Timer (com.codahale.metrics.Timer)1 CachedThreadStatesGaugeSet (com.codahale.metrics.jvm.CachedThreadStatesGaugeSet)1