Created
June 9, 2017 02:23
-
-
Save johann8384/dc92bfb3fb88197ed48de12acc23a5ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static { | |
// Collect jvm and system metrics by default | |
Metrics.registerMetricSet("jvm.gc", new GarbageCollectorMetricSet()); | |
Metrics.registerMetricSet("jvm.memory", new MemoryUsageGaugeSet()); | |
Metrics.registerMetricSet("jvm.threads", new ThreadStatesGaugeSet()); | |
Metrics.registerMetricSet("jvm.runtime", new RuntimeMetricSet()); | |
Metrics.registerMetricSet("jvm.os", new OperatingSystemMetricSet()); | |
Metrics.registerMetricSet("jvm.filesystem", new FileSystemMetricSet()); | |
Metrics.registerAll("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()), Metrics.getMetricRegistry()); | |
// Register the basic health check | |
Metrics.registerHealthCheck("DeadlockDetection", new ThreadDeadlockHealthCheck()); | |
// Register metrics for the logger (it's the WTF per second metric, very important) | |
final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory(); | |
final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME); | |
final InstrumentedAppender metrics = new InstrumentedAppender(registry); | |
metrics.setContext(root.getLoggerContext()); | |
metrics.start(); | |
root.addAppender(metrics); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment