Search in sources :

Example 21 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet 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());
        }
    }
    if (bulkOperationMetrics != null) {
        Map<String, Metric> metrics = bulkOperationMetrics.getMetrics();
        for (Map.Entry<String, Metric> metric : metrics.entrySet()) {
            metricRegistry.register(metric.getKey(), metric.getValue());
        }
    }
}
Also used : JvmAttributeGaugeSet(com.codahale.metrics.JvmAttributeGaugeSet) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) Metric(com.codahale.metrics.Metric) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) Map(java.util.Map) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet)

Example 22 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project infrautils by opendaylight.

the class MetricProviderImpl method setUpJvmMetrics.

private static void setUpJvmMetrics(MetricRegistry registry) {
    ThreadDeadlockDetector threadDeadlockDetector = new ThreadDeadlockDetector();
    FileDescriptorRatioGauge fileDescriptorRatioGauge = new FileDescriptorRatioGauge();
    registry.registerAll(new GarbageCollectorMetricSet());
    registry.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
    registry.registerAll(new CachedThreadStatesGaugeSet(getThreadMXBean(), threadDeadlockDetector, 13, SECONDS));
    registry.registerAll(new MemoryUsageGaugeSet());
    registry.registerAll(new ClassLoadingGaugeSet());
    registry.gauge("odl.infrautils.FileDescriptorRatio", () -> fileDescriptorRatioGauge);
}
Also used : BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) FileDescriptorRatioGauge(com.codahale.metrics.jvm.FileDescriptorRatioGauge) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) ThreadDeadlockDetector(com.codahale.metrics.jvm.ThreadDeadlockDetector) ClassLoadingGaugeSet(com.codahale.metrics.jvm.ClassLoadingGaugeSet) CachedThreadStatesGaugeSet(com.codahale.metrics.jvm.CachedThreadStatesGaugeSet) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet)

Example 23 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet 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.");
}
Also used : InstrumentedAppender(com.codahale.metrics.logback.InstrumentedAppender) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) ClassLoadingGaugeSet(com.codahale.metrics.jvm.ClassLoadingGaugeSet) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) LoggerContext(ch.qos.logback.classic.LoggerContext) JmxReporter(com.codahale.metrics.JmxReporter) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) Start(ninja.lifecycle.Start)

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