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;
}
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());
}
}
}
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"));
}
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);
}
Aggregations