use of com.codahale.metrics.jvm.ClassLoadingGaugeSet 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.jvm.ClassLoadingGaugeSet 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.");
}
use of com.codahale.metrics.jvm.ClassLoadingGaugeSet 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);
}
}
Aggregations