@Override protected Ratio getRatio() { return Ratio.of(sizeGauge.getValue(), sizeLimitGauge.getValue()); } });
@Override public Map<MetricId, Metric> getMetrics() { final Map<MetricId, Metric> gauges = new HashMap<>(); final MetricId metricId = MetricId.build().tagged("what", "file-descriptor-ratio", "unit", "%"); gauges.put(metricId, (Gauge<Object>) () -> { try { return fileDescriptorRatioGauge.getValue(); } catch (final Exception ex) { LOG.debug("Failed to get metrics for FileDescriptorGaugeSet", ex); // This is what the upstream FileDescriptorRatioGauge returns when an exception occurs. return RatioGauge.Ratio.of(Double.NaN, Double.NaN); } }); return Collections.unmodifiableMap(gauges); } });
protected Ratio getRatio() { double req = requests.getOneMinuteRate(); double mis = misses.getOneMinuteRate(); return Ratio.of(req - mis, req); } });
@Override public Ratio getRatio() { long req = requests.getCount(); long mis = misses.getCount(); return Ratio.of(req - mis, req); } });
protected Ratio getRatio() { return Ratio.of(hits.getFifteenMinuteRate(), requests.getFifteenMinuteRate()); } });
@Override public Ratio getRatio() { return Ratio.of(hits.getCount(), requests.getCount()); } });
@Override protected Ratio getRatio() { final MemoryUsage usage = mxBean.getNonHeapMemoryUsage(); return Ratio.of(usage.getUsed(), usage.getMax()); } });
RatioGauge metaMetrics = (RatioGauge) METRICS.getMetricRegistry() .getMetrics().get(METRICS.getMetaPoolName()); assertEquals(Ratio.of(0, 3).getValue(), executorMetrics.getValue(), 0); assertEquals(Double.NaN, metaMetrics.getValue(), 0);
RatioGauge metaMetrics = (RatioGauge) METRICS.getMetricRegistry() .getMetrics().get(METRICS.getMetaPoolName()); assertEquals(Ratio.of(0, 3).getValue(), executorMetrics.getValue(), 0); assertEquals(Double.NaN, metaMetrics.getValue(), 0);
private Supplier<Ratio> errorRatioSupplier(Supplier<Double> errorRateSupplier, Supplier<Double> replyRateSupplier) { // We limit both the denominator and the resulting ratio when calculating error ratios. // // The ratio is limited in order to avoid producing ratios that are arbitrarily close to zero // but not quite zero. Them being close to but not quite zero is not a problem per se but it // distorts the apparent meaning of graphs in some monitoring tools - when the ratio goes // from e.g. 1e-316 to 1e-300 it can look like a huge increase indicating that something // sinister is in the works even though the error ratio is basically nil. // // The denominator is limited to avoid noise in the ratio when the total reply rate is low, // dividing by a EWMA-computed rate can cause ratios that are higher than the true ratio due to // computational noise in the EWMA computations. // If a service is drained of traffic (for instance by moving traffic to another host or site), // the meter values will decay exponentially towards zero. If left for some time (hours), // rounding errors will cause the values of the meters to approach each other, thus skewing // the ratio. If an alert is tied to this ratio, it may trigger falsely. To fix this, we set a // minimum for the denominator in the ratio, effectively making sure it will be be bigger than // the error rate as both rates goes towards zero. return () -> { final double denominator = max(replyRateSupplier.get(), ERROR_GAUGE_MINIMUM_REPLY_RATE); final Ratio ratio = Ratio.of(errorRateSupplier.get(), denominator); return ratio.getValue() > ERROR_RATIO_MINIMUM ? ratio : Ratio.of(0, denominator); }; }
public Ratio getHitRatio1Min() { final Meter hitRate = registry.meter(allCacheHitsMetricName); final Meter missRate = registry.meter(allCacheMissesMetricName); final double oneMinuteHitRate = hitRate.getOneMinuteRate(); return Ratio.of(oneMinuteHitRate * 100.0, oneMinuteHitRate + missRate.getOneMinuteRate()); }
@Override protected Ratio getRatio() { return Ratio.of(pooledResource.getPoolNumActive() * 100.0, pooledResource.getMaxPoolSize()); } });
@Override protected Ratio getRatio() { return RatioGauge.Ratio.of(success.getFiveMinuteRate(), attempts.getFiveMinuteRate()); } }
@Override protected Ratio getRatio() { return Ratio.of(getSnapshot().getUsed(), getSnapshot().getTotal() * 100.0); } });