public <V> Gauge<V> registerGauge(final String name, Gauge<V> gauge) { return registry.gauge(name, () -> gauge); }
@Subscribe public void requestStart(AddLabelledQuery<T> data) { if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", () -> new InstantGauge())) .increment(); } }
@Subscribe public void requestStart(AddQuery<T> data) { registry.meter(prefix + ".requests-started") .mark(); registry.counter(prefix + ".requests-started-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-interval-count", () -> new InstantGauge())).increment(); if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); registry.meter(queryStartName(rd) + "-meter") .mark(); queries.start(rd.getCorrelationId(), timer(queryEndName(rd) + "-timer").time()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", () -> new InstantGauge())).increment(); } }
@Subscribe public void requestComplete(RemoveQuery<T> data) { registry.meter(prefix + ".requests-completed") .mark(); registry.counter(prefix + ".requests-completed-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-interval-count", () -> new InstantGauge())) .increment(); if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); registry.meter(queryEndName(rd)) .mark(); queries.complete(rd.getCorrelationId()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .dec(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", () -> new InstantGauge())).increment(); } }
@Subscribe public void requestComplete(RemoveLabelledQuery<T> data) { if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", () -> new InstantGauge())) .increment(); } }
public LegacySweepMetrics(MetricRegistry metricRegistry) { this.cellsExamined = metricRegistry.counter(getMetricName(AtlasDbMetricNames.CELLS_EXAMINED)); this.cellsDeleted = metricRegistry.counter(getMetricName(AtlasDbMetricNames.CELLS_SWEPT)); this.timeSweeping = metricRegistry.counter(getMetricName(AtlasDbMetricNames.TIME_SPENT_SWEEPING)); this.sweepErrors = metricRegistry.counter(getMetricName(AtlasDbMetricNames.SWEEP_ERROR)); this.totalTime = new CurrentValueMetric<>(); metricRegistry.gauge(getMetricName(AtlasDbMetricNames.TIME_ELAPSED_SWEEPING), () -> totalTime); }
@Override public <T> GaugeRegistry register(String name, Gauge<T> gauge) { metricRegistry.gauge(name, () -> gauge::get); return this; } }
@Override public <T> GaugeRegistry register(String name, Gauge<T> gauge) { metricRegistry.gauge(name, () -> gauge::get); return this; } }
public static Gauge gauge(String name, MetricRegistry.MetricSupplier<Gauge> supplier) { // Some of our gauges are backed by connections to Couchbase or other server. // These must be recreated for each connection, so remove first. registry.remove(PREFIX + name); return registry.gauge(PREFIX + name, supplier); }
public static void updatePlanStatus(Optional<String> namespace, String planName, Status status) { final String metricName = namespace.isPresent() ? String.format("plan_status.%s.%s", namespace.get(), planName) : String.format("plan_status.%s", planName); // Returns the existing PlanGauge, or the provided new PlanGauge if none was configured yet: PlanGauge newOrExistingGauge = (PlanGauge) METRICS.gauge(metricName, PlanGauge::new); newOrExistingGauge.setStatus(status); }
public LegacySweepMetrics(MetricRegistry metricRegistry) { this.cellsExamined = metricRegistry.counter(getMetricName(AtlasDbMetricNames.CELLS_EXAMINED)); this.cellsDeleted = metricRegistry.counter(getMetricName(AtlasDbMetricNames.CELLS_SWEPT)); this.timeSweeping = metricRegistry.counter(getMetricName(AtlasDbMetricNames.TIME_SPENT_SWEEPING)); this.sweepErrors = metricRegistry.counter(getMetricName(AtlasDbMetricNames.SWEEP_ERROR)); this.totalTime = new CurrentValueMetric<>(); metricRegistry.gauge(getMetricName(AtlasDbMetricNames.TIME_ELAPSED_SWEEPING), () -> totalTime); }
Temperature temp = new Temperature("/sys/class/thermal/thermal_zone0/temp"); if (temp.isAvailable()) { REGISTRY.gauge("temperature", temp); } else { LOG.info("temperature metric is not available"); LOG.info("CPU count: {}", Runtime.getRuntime().availableProcessors()); REGISTRY.gauge("heap", new MetricSupplier<Gauge>() { @Override public Gauge<?> newMetric() { File f = sigar.getNativeLibrary(); if (f != null && f.exists()) { REGISTRY.gauge("load-average", new MetricSupplier<Gauge>() { @Override public Gauge<?> newMetric() { REGISTRY.gauge("ram-used", new MetricSupplier<Gauge>() { @Override public Gauge<?> newMetric() { REGISTRY.gauge("disk-used", new MetricSupplier<Gauge>() { @Override public Gauge<?> newMetric() {
@Subscribe public void requestStart(AddQuery<T> data) { registry.meter(prefix + ".requests-started") .mark(); registry.counter(prefix + ".requests-started-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-interval-count", () -> new InstantGauge())).increment(); if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); registry.meter(queryStartName(rd) + "-meter") .mark(); queries.start(rd.getCorrelationId(), timer(queryEndName(rd) + "-timer").time()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", () -> new InstantGauge())).increment(); } }
@Subscribe public void requestStart(AddLabelledQuery<T> data) { if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); ((InstantGauge) registry.gauge(prefix + ".requests-started-" + rd.getType() + "-interval-count", () -> new InstantGauge())) .increment(); } }
@Subscribe public void requestComplete(RemoveLabelledQuery<T> data) { if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", () -> new InstantGauge())) .increment(); } }
@Subscribe public void requestComplete(RemoveQuery<T> data) { registry.meter(prefix + ".requests-completed") .mark(); registry.counter(prefix + ".requests-completed-count") .inc(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-interval-count", () -> new InstantGauge())) .increment(); if (this.configuration.isQueriesByType()) { RequestData<T> rd = data.getData(); registry.meter(queryEndName(rd)) .mark(); queries.complete(rd.getCorrelationId()); registry.counter(prefix + ".requests-active-" + rd.getType() + "-count") .dec(); ((InstantGauge) registry.gauge(prefix + ".requests-completed-" + rd.getType() + "-interval-count", () -> new InstantGauge())).increment(); } }
Metrics.REGISTRY.gauge("ppm", new MetricSupplier<Gauge>() {
this.failureProcessedThroughput = metricRegistry.meter(name(metricsPrefix, FAILURE_PROCESSED_THROUGHPUT)); this.totalProcessedThroughput = metricRegistry.meter(name(metricsPrefix, TOTAL_PROCESSED_THROUGHPUT)); metricRegistry.gauge(name(metricsPrefix, QUEUE_SIZE), () -> () -> queue.size());
this.registry.gauge( buildFullName(DefaultSessionMetric.CONNECTED_NODES, null), () -> this.registry.gauge( buildFullName(DefaultSessionMetric.THROTTLING_QUEUE_SIZE, null), () -> buildQueueGauge(context.getRequestThrottler(), context.getSessionName())); this.registry.gauge( buildFullName(DefaultSessionMetric.CQL_PREPARED_CACHE_SIZE, null), () -> {
this.failureProcessedThroughput = metricRegistry.meter(name(metricsPrefix, FAILURE_PROCESSED_THROUGHPUT)); this.totalProcessedThroughput = metricRegistry.meter(name(metricsPrefix, TOTAL_PROCESSED_THROUGHPUT)); metricRegistry.gauge(name(metricsPrefix, QUEUE_SIZE), () -> () -> queue.size());