@PostConstruct public void init() { /* * consoleReporter = ConsoleReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) * .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); consoleReporter.start(1, TimeUnit.SECONDS); */ GarbageCollectorMetricSet gc = new GarbageCollectorMetricSet(); // FileDescriptorRatioGauge fd = new FileDescriptorRatioGauge(); MemoryUsageGaugeSet mu = new MemoryUsageGaugeSet(); // ThreadDeadlockDetector td = new ThreadDeadlockDetector(); // ThreadDump t = new ThreadDump(); ThreadStatesGaugeSet ts = new ThreadStatesGaugeSet(); metricRegistry.register("GarbageCollector", gc); // registry.register(FileDescriptorRatioGauge.class.getName(), fd); metricRegistry.register("MemoryUsage", mu); // registry.register(ThreadDeadlockDetector.class.getName(), td); // registry.registerAll(t); metricRegistry.register("ThreadStates", ts); healthCheckRegistry.register("threadDeadlock", new ThreadDeadlockHealthCheck()); }
/** * Will initialize Moneta given a configuration. This <b>must</b> be executed before use. * @param config XML configuration */ protected final void init(XMLConfiguration config) { initDataSources(config); initTopics(config); healthChecks.put("Deadlock", new ThreadDeadlockHealthCheck()); initRun = true; }
private void registerHealthChecks( Application application, HealthCheckRegistry healthChecks ) { Config config = application.config().atKey( "metrics" ); // JVM HealthChecks if( config.bool( "healthchecks.deadlocks.enabled" ) ) { healthChecks.register( "jvm.deadlocks", new ThreadDeadlockHealthCheck() ); } }
public RegisterJVMMetrics(CommandBuilder builder, Config config, Command parent, Command child, final MorphlineContext context) { super(builder, config, parent, child, context); validateArguments(); MetricRegistry registry = context.getMetricRegistry(); BufferPoolMetricSet bufferPoolMetrics = new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()); registerAll("jvm.buffers", bufferPoolMetrics, registry); registerAll("jvm.gc", new GarbageCollectorMetricSet(), registry); registerAll("jvm.memory", new MemoryUsageGaugeSet(), registry); registerAll("jvm.threads", new ThreadStatesGaugeSet(), registry); register("jvm.fileDescriptorCountRatio", new FileDescriptorRatioGauge(), registry); context.getHealthCheckRegistry().register("deadlocks", new ThreadDeadlockHealthCheck()); }
/** * Initializer method for the metrics registry. Call this method before registering * new metrics with the registry. */ public static void init() { // Metrics registries will be initialized only if enabled if(!Configuration.root().getBoolean("metrics", false)) { LOGGER.debug("Metrics not enabled in the conf file."); return; } // Metrics & healthcheck registries will be initialized only once if(_metricRegistry != null) { LOGGER.debug("Metric registries already initialized."); return; } _metricRegistry = new MetricRegistry(); String className = AnalyticJob.class.getSimpleName(); _skippedJobs = _metricRegistry.meter(name(className, "skippedJobs", "count")); _processedJobs = _metricRegistry.meter(name(className, "processedJobs", "count")); _jobProcessingTime = _metricRegistry.histogram(name(className, "jobProcessingTime", "ms")); _metricRegistry.register(name(className, "jobQueue", "size"), new Gauge<Integer>() { @Override public Integer getValue() { return _queueSize; } }); _metricRegistry.register(name(className, "lastDayJobs", "count"), new Gauge<Integer>() { private static final long DAY = 24 * 60 * 60 * 1000; private static final long UPDATE_DELAY = 60 * 1000; private long _lastUpdate = 0; private int _count = -1; @Override public Integer getValue() { long now = System.currentTimeMillis(); if (now - _lastUpdate > UPDATE_DELAY) { _count = AppResult.find.where() .gt(AppResult.TABLE.FINISH_TIME, now - DAY) .findRowCount(); _lastUpdate = now; } return _count; } }); _metricRegistry.register(name(className, "retryQueue", "size"), new Gauge<Integer>() { @Override public Integer getValue() { return _retryQueueSize; } }); _metricRegistry.registerAll(new CustomGarbageCollectorMetricSet()); _metricRegistry.registerAll(new MemoryUsageGaugeSet()); JmxReporter.forRegistry(_metricRegistry).build().start(); _healthCheckRegistry = new HealthCheckRegistry(); _healthCheckRegistry.register("ThreadDeadlockHealthCheck", new ThreadDeadlockHealthCheck()); }
@Autowired public void setHealthCheckRegistry(HealthCheckRegistry registry) { registry.register(ThreadDeadlockHealthCheck.class.getName(), new ThreadDeadlockHealthCheck()); }
public HealthCheck get() { return new ThreadDeadlockHealthCheck(); }
@PostConstruct public void init() { ThreadDeadlockHealthCheck threadDeadlockHealthCheck = new ThreadDeadlockHealthCheck(); healthCheckRegistry.register("threadDeadlockHealthCheck", threadDeadlockHealthCheck); }
protected void configureHealthChecks() { HealthCheckRegistry healthCheckRegistry = getHealthCheckRegistry(); healthCheckRegistry.register("threadDeadlock", new ThreadDeadlockHealthCheck()); }