@Inject public CassMonitorMetrics(Registry registry) { cassStop = registry.gauge(Metrics.METRIC_PREFIX + "cass.stop"); cassStart = registry.gauge(Metrics.METRIC_PREFIX + "cass.start"); cassAutoStart = registry.gauge(Metrics.METRIC_PREFIX + "cass.auto.start"); getSeedsCnt = PolledMeter.using(registry) .withName(Metrics.METRIC_PREFIX + "cass.getSeedCnt") .monitorMonotonicCounter(new AtomicLong(0)); getTokenCnt = PolledMeter.using(registry) .withName(Metrics.METRIC_PREFIX + "cass.getTokenCnt") .monitorMonotonicCounter(new AtomicLong(0)); getReplacedIpCnt = PolledMeter.using(registry) .withName(Metrics.METRIC_PREFIX + "cass.getReplacedIpCnt") .monitorMonotonicCounter(new AtomicLong(0)); doubleRingCnt = PolledMeter.using(registry) .withName(Metrics.METRIC_PREFIX + "cass.doubleRingCnt") .monitorMonotonicCounter(new AtomicLong(0)); }
new ArrayBlockingQueue<>(configuration.getBackupQueueSize()); PolledMeter.using(backupMetrics.getRegistry()) .withName(backupMetrics.uploadQueueSize) .monitorSize(uploadQueue); this.fileUploadExecutor = new ArrayBlockingQueue<>(configuration.getDownloadQueueSize()); PolledMeter.using(backupMetrics.getRegistry()) .withName(backupMetrics.downloadQueueSize) .monitorSize(downloadQueue); this.fileDownloadExecutor =
.withName("genie.tasks.databaseCleanup.numDeletedJobs.gauge") .monitorValue(new AtomicLong()); this.numDeletedClusters = PolledMeter .using(registry) .withName("genie.tasks.databaseCleanup.numDeletedClusters.gauge") .monitorValue(new AtomicLong()); this.numDeletedTags = PolledMeter .using(registry) .withName("genie.tasks.databaseCleanup.numDeletedTags.gauge") .monitorValue(new AtomicLong()); this.numDeletedFiles = PolledMeter .using(registry) .withName("genie.tasks.databaseCleanup.numDeletedFiles.gauge") .monitorValue(new AtomicLong()); this.deletionTimerId = registry.createId("genie.tasks.databaseCleanup.duration.timer");
.withName("genie.tasks.clusterChecker.errorCounts.gauge") .monitorSize(this.errorCounts); this.lostJobsCounter = registry.counter("genie.tasks.clusterChecker.lostJobs.rate");
.withName("genie.tasks.diskCleanup.numberDeletedJobDirs.gauge") .monitorValue(new AtomicLong()); this.numberOfDirsUnableToDelete = PolledMeter .using(registry) .withName("genie.tasks.diskCleanup.numberDirsUnableToDelete.gauge") .monitorValue(new AtomicLong()); this.unableToGetJobCounter = registry.counter("genie.tasks.diskCleanup.unableToGetJobs.rate");
.withName("genie.jobs.file.cache.hitRate") .monitorValue(this.fileCache, value -> value.stats().hitRate()); .withName("genie.jobs.file.cache.missRate") .monitorValue(this.fileCache, value -> value.stats().missRate()); .withName("genie.jobs.file.cache.loadExceptionRate") .monitorValue(this.fileCache, value -> value.stats().loadExceptionRate());
.withName(TASK_COUNT) .withTag(idTag) .monitorMonotonicCounter(threadPool, ThreadPoolExecutor::getTaskCount); PolledMeter.using(registry) .withName(COMPLETED_TASK_COUNT) .withTag(idTag) .monitorMonotonicCounter(threadPool, ThreadPoolExecutor::getCompletedTaskCount); PolledMeter.using(registry) .withName(CURRENT_THREADS_BUSY) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getActiveCount); PolledMeter.using(registry) .withName(MAX_THREADS) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getMaximumPoolSize); PolledMeter.using(registry) .withName(POOL_SIZE) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getPoolSize); PolledMeter.using(registry) .withName(CORE_POOL_SIZE) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getCorePoolSize); PolledMeter.using(registry) .withName(QUEUE_SIZE) .withTag(idTag) .monitorValue(threadPool, tp -> tp.getQueue().size());
.withName(TASK_COUNT) .withTag(idTag) .monitorMonotonicCounter(threadPool, ThreadPoolExecutor::getTaskCount); PolledMeter.using(registry) .withName(COMPLETED_TASK_COUNT) .withTag(idTag) .monitorMonotonicCounter(threadPool, ThreadPoolExecutor::getCompletedTaskCount); PolledMeter.using(registry) .withName(CURRENT_THREADS_BUSY) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getActiveCount); PolledMeter.using(registry) .withName(MAX_THREADS) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getMaximumPoolSize); PolledMeter.using(registry) .withName(POOL_SIZE) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getPoolSize); PolledMeter.using(registry) .withName(CORE_POOL_SIZE) .withTag(idTag) .monitorValue(threadPool, ThreadPoolExecutor::getCorePoolSize); PolledMeter.using(registry) .withName(QUEUE_SIZE) .withTag(idTag) .monitorValue(threadPool, tp -> tp.getQueue().size());
@Test public void uncaughtExceptionFromGaugeFunction() { Assertions.assertThrows(RuntimeException.class, () -> { Registry registry = new DefaultRegistry(); PolledMeter.using(registry) .withName("test") .monitorValue(new RuntimeException("failure"), value -> { throw value; }); PolledMeter.update(registry); }); } }
@Test public void builderWithThresholdDuration() { Registry r = newRegistry(); PercentileTimer t = PercentileTimer.builder(r) .withName("test") .withRange(Duration.ZERO, Duration.ofSeconds(100)) .build(); checkPercentiles(t, 0); } }
@Test public void builder() { Registry r = newRegistry(); PercentileDistributionSummary t = PercentileDistributionSummary.builder(r) .withName("test") .build(); checkPercentiles(t, 0); }
@Test public void builderWithThreshold() { Registry r = newRegistry(); PercentileTimer t = PercentileTimer.builder(r) .withName("test") .withRange(10, 100, TimeUnit.SECONDS) .build(); checkPercentiles(t, 10); }