Search in sources :

Example 11 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project curiostack by curioswitch.

the class MonitoringModule method configureJvmMetrics.

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

Example 12 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project lucene-solr by apache.

the class SolrDispatchFilter method setupJvmMetrics.

private void setupJvmMetrics(CoreContainer coresInit) {
    SolrMetricManager metricManager = coresInit.getMetricManager();
    final Set<String> hiddenSysProps = coresInit.getConfig().getMetricsConfig().getHiddenSysProps();
    try {
        String registry = SolrMetricManager.getRegistryName(SolrInfoBean.Group.jvm);
        metricManager.registerAll(registry, new AltBufferPoolMetricSet(), true, "buffers");
        metricManager.registerAll(registry, new ClassLoadingGaugeSet(), true, "classes");
        metricManager.registerAll(registry, new OperatingSystemMetricSet(), true, "os");
        metricManager.registerAll(registry, new GarbageCollectorMetricSet(), true, "gc");
        metricManager.registerAll(registry, new MemoryUsageGaugeSet(), true, "memory");
        // todo should we use CachedThreadStatesGaugeSet instead?
        metricManager.registerAll(registry, new ThreadStatesGaugeSet(), true, "threads");
        MetricsMap sysprops = new MetricsMap((detailed, map) -> {
            System.getProperties().forEach((k, v) -> {
                if (!hiddenSysProps.contains(k)) {
                    map.put(String.valueOf(k), v);
                }
            });
        });
        metricManager.registerGauge(null, registry, sysprops, true, "properties", "system");
    } catch (Exception e) {
        log.warn("Error registering JVM metrics", e);
    }
}
Also used : MetricsMap(org.apache.solr.metrics.MetricsMap) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) OperatingSystemMetricSet(org.apache.solr.metrics.OperatingSystemMetricSet) SolrMetricManager(org.apache.solr.metrics.SolrMetricManager) AltBufferPoolMetricSet(org.apache.solr.metrics.AltBufferPoolMetricSet) ClassLoadingGaugeSet(com.codahale.metrics.jvm.ClassLoadingGaugeSet) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) ServletException(javax.servlet.ServletException) SolrException(org.apache.solr.common.SolrException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet)

Example 13 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet 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;
}
Also used : FileDescriptorRatioGauge(com.codahale.metrics.jvm.FileDescriptorRatioGauge) MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) ThreadStatesGaugeSet(com.codahale.metrics.jvm.ThreadStatesGaugeSet) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) Bean(org.springframework.context.annotation.Bean)

Example 14 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project bookkeeper by apache.

the class CodahaleMetricsProvider method initIfNecessary.

synchronized void initIfNecessary() {
    if (metrics == null) {
        metrics = new MetricRegistry();
        metrics.registerAll(new MemoryUsageGaugeSet());
        metrics.registerAll(new GarbageCollectorMetricSet());
    }
}
Also used : MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet)

Example 15 with GarbageCollectorMetricSet

use of com.codahale.metrics.jvm.GarbageCollectorMetricSet in project microservices by pwillhan.

the class MetricSystem method init.

@PostConstruct
public void init() {
    // ConsoleReporter consoleReporter = ConsoleReporter.forRegistry(metricRegistry)
    // .convertRatesTo(TimeUnit.SECONDS)
    // .convertDurationsTo(TimeUnit.MILLISECONDS)
    // .build();
    // 
    // consoleReporter.start(10, TimeUnit.SECONDS);
    // Graphite graphite = new Graphite(new InetSocketAddress("192.168.99.100", 2003));
    // GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry)
    // .prefixedWith("com.packt.microservices.geolocation")
    // .convertRatesTo(TimeUnit.SECONDS)
    // .convertDurationsTo(TimeUnit.MILLISECONDS)
    // .filter(MetricFilter.ALL)
    // .build(graphite);
    // graphiteReporter.start(60, TimeUnit.SECONDS);
    geolocationWriteRequestCount = metricRegistry.counter("geolocationWriteRequestCount");
    metricRegistry.register("geolocationLastWriteTime", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return geolocationLastWriteTime;
        }
    });
    metricRegistry.registerAll(new MetricSet() {

        @Override
        public Map<String, Metric> getMetrics() {
            Map<String, Metric> metrics = new HashMap<>();
            metrics.put("geolocationMemoryUsage", new MemoryUsageGaugeSet());
            metrics.put("geolocationClassLoading", new ClassLoadingGaugeSet());
            metrics.put("geolocationGarbageCollector", new GarbageCollectorMetricSet());
            return metrics;
        }
    });
}
Also used : MemoryUsageGaugeSet(com.codahale.metrics.jvm.MemoryUsageGaugeSet) ClassLoadingGaugeSet(com.codahale.metrics.jvm.ClassLoadingGaugeSet) HashMap(java.util.HashMap) Map(java.util.Map) MetricSet(com.codahale.metrics.MetricSet) GarbageCollectorMetricSet(com.codahale.metrics.jvm.GarbageCollectorMetricSet) 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