Search in sources :

Example 1 with JvmAttributeGaugeSet

use of com.codahale.metrics.JvmAttributeGaugeSet 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;
}
Also used : BufferPoolMetricSet(com.codahale.metrics.jvm.BufferPoolMetricSet) JvmAttributeGaugeSet(com.codahale.metrics.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 2 with JvmAttributeGaugeSet

use of com.codahale.metrics.JvmAttributeGaugeSet 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());
        }
    }
}
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 3 with JvmAttributeGaugeSet

use of com.codahale.metrics.JvmAttributeGaugeSet in project sling by apache.

the class JSONReporterTest method jsonOutput.

@SuppressWarnings("unchecked")
@Test
public void jsonOutput() throws Exception {
    MetricRegistry registry = new MetricRegistry();
    registry.meter("test1").mark(5);
    registry.timer("test2").time().close();
    registry.histogram("test3").update(743);
    registry.counter("test4").inc(9);
    registry.registerAll(new JvmAttributeGaugeSet());
    Map<String, Object> json = getJSON(registry);
    assertTrue(json.containsKey("meters"));
    assertTrue(json.containsKey("gauges"));
    assertTrue(json.containsKey("timers"));
    assertTrue(json.containsKey("counters"));
    assertTrue(json.containsKey("histograms"));
    assertTrue(json.containsKey("meters"));
    assertTrue(((Map<String, Object>) json.get("meters")).containsKey("test1"));
    assertTrue(((Map<String, Object>) json.get("timers")).containsKey("test2"));
    assertTrue(((Map<String, Object>) json.get("counters")).containsKey("test4"));
    assertTrue(((Map<String, Object>) json.get("histograms")).containsKey("test3"));
}
Also used : JvmAttributeGaugeSet(com.codahale.metrics.JvmAttributeGaugeSet) MetricRegistry(com.codahale.metrics.MetricRegistry) Test(org.junit.Test)

Example 4 with JvmAttributeGaugeSet

use of com.codahale.metrics.JvmAttributeGaugeSet in project sling by apache.

the class MetricWebConsolePluginTest method webConsolePlugin.

@Test
public void webConsolePlugin() throws Exception {
    MetricRegistry reg1 = new MetricRegistry();
    reg1.meter("test1").mark(5);
    reg1.timer("test2").time().close();
    reg1.histogram("test3").update(743);
    reg1.counter("test4").inc(9);
    reg1.registerAll(new JvmAttributeGaugeSet());
    context.registerService(MetricRegistry.class, reg1, regProps("foo"));
    activatePlugin();
    StringWriter sw = new StringWriter();
    HttpServletResponse response = mock(HttpServletResponse.class);
    when(response.getWriter()).thenReturn(new PrintWriter(sw));
    plugin.doGet(mock(HttpServletRequest.class), response);
    WebClient client = new WebClient();
    WebResponse resp = new StringWebResponse(sw.toString(), WebClient.URL_ABOUT_BLANK);
    HtmlPage page = HTMLParser.parseHtml(resp, client.getCurrentWindow());
    assertTable("data-meters", page);
    assertTable("data-counters", page);
    assertTable("data-timers", page);
    assertTable("data-histograms", page);
    assertTable("data-gauges", page);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JvmAttributeGaugeSet(com.codahale.metrics.JvmAttributeGaugeSet) StringWebResponse(com.gargoylesoftware.htmlunit.StringWebResponse) WebResponse(com.gargoylesoftware.htmlunit.WebResponse) StringWebResponse(com.gargoylesoftware.htmlunit.StringWebResponse) StringWriter(java.io.StringWriter) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) MetricRegistry(com.codahale.metrics.MetricRegistry) HttpServletResponse(javax.servlet.http.HttpServletResponse) WebClient(com.gargoylesoftware.htmlunit.WebClient) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

JvmAttributeGaugeSet (com.codahale.metrics.JvmAttributeGaugeSet)4 MetricRegistry (com.codahale.metrics.MetricRegistry)2 GarbageCollectorMetricSet (com.codahale.metrics.jvm.GarbageCollectorMetricSet)2 MemoryUsageGaugeSet (com.codahale.metrics.jvm.MemoryUsageGaugeSet)2 ThreadStatesGaugeSet (com.codahale.metrics.jvm.ThreadStatesGaugeSet)2 Test (org.junit.Test)2 Metric (com.codahale.metrics.Metric)1 BufferPoolMetricSet (com.codahale.metrics.jvm.BufferPoolMetricSet)1 ClassLoadingGaugeSet (com.codahale.metrics.jvm.ClassLoadingGaugeSet)1 FileDescriptorRatioGauge (com.codahale.metrics.jvm.FileDescriptorRatioGauge)1 StringWebResponse (com.gargoylesoftware.htmlunit.StringWebResponse)1 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Map (java.util.Map)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1