@Override public double getRate() { return meter.getOneMinuteRate(); }
@Override public double getOneMinuteRate() { return meter.getOneMinuteRate(); }
@Override public double getOneMinuteRate() { return meter.getOneMinuteRate(); }
public static Map<String, Object> buildMeterMap(Meter m) { Map<String, Object> metrics = Maps.newHashMap(); if (m == null) { return metrics; } Map<String, Object> rate = Maps.newHashMap(); rate.put("one_minute", m.getOneMinuteRate()); rate.put("five_minute", m.getFiveMinuteRate()); rate.put("fifteen_minute", m.getFifteenMinuteRate()); rate.put("total", m.getCount()); rate.put("mean", m.getMeanRate()); metrics.put("rate_unit", "events/second"); metrics.put("rate", rate); return metrics; }
@Override public Map<String, Object> getMovingAverages() { Map<String, Object> movingAverages = new HashMap<>(); Map<String, Object> oneMinute = new HashMap<>(); oneMinute.put(PROCESSED, processed.getOneMinuteRate()); oneMinute.put(PROCESSED_WITH_ERROR, processedWithError.getOneMinuteRate()); oneMinute.put(UNPARSEABLE, unparseable.getOneMinuteRate()); oneMinute.put(THROWN_AWAY, thrownAway.getOneMinuteRate()); Map<String, Object> fiveMinute = new HashMap<>(); fiveMinute.put(PROCESSED, processed.getFiveMinuteRate()); fiveMinute.put(PROCESSED_WITH_ERROR, processedWithError.getFiveMinuteRate()); fiveMinute.put(UNPARSEABLE, unparseable.getFiveMinuteRate()); fiveMinute.put(THROWN_AWAY, thrownAway.getFiveMinuteRate()); Map<String, Object> fifteenMinute = new HashMap<>(); fifteenMinute.put(PROCESSED, processed.getFifteenMinuteRate()); fifteenMinute.put(PROCESSED_WITH_ERROR, processedWithError.getFifteenMinuteRate()); fifteenMinute.put(UNPARSEABLE, unparseable.getFifteenMinuteRate()); fifteenMinute.put(THROWN_AWAY, thrownAway.getFifteenMinuteRate()); movingAverages.put(ONE_MINUTE_NAME, oneMinute); movingAverages.put(FIVE_MINUTE_NAME, fiveMinute); movingAverages.put(FIFTEEN_MINUTE_NAME, fifteenMinute); return movingAverages; } }
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()); }
public MeterRates(Meter meter) { this(meter.getOneMinuteRate(), meter.getFiveMinuteRate(), meter.getFifteenMinuteRate()); }
private static List<Metric> allMetrics(MetricsSystem.InstanceType instanceType) { List<Metric> metrics = new ArrayList<>(); for (Entry<String, Gauge> entry : METRIC_REGISTRY.getGauges().entrySet()) { if (entry.getKey().startsWith(instanceType.toString())) { Object value = entry.getValue().getValue(); if (!(value instanceof Number)) { LOG.warn( "The value of metric {} of type {} is not sent to metrics master," + " only metrics value of number can be collected", entry.getKey(), entry.getValue().getClass().getSimpleName()); continue; } metrics.add(Metric.from(entry.getKey(), ((Number) value).longValue())); } } for (Entry<String, Counter> entry : METRIC_REGISTRY.getCounters().entrySet()) { metrics.add(Metric.from(entry.getKey(), entry.getValue().getCount())); } for (Entry<String, Meter> entry : METRIC_REGISTRY.getMeters().entrySet()) { // TODO(yupeng): From Meter's implementation, getOneMinuteRate can only report at rate of at // least seconds. if the client's duration is too short (i.e. < 1s), then getOneMinuteRate // would return 0 metrics.add(Metric.from(entry.getKey(), entry.getValue().getOneMinuteRate())); } for (Entry<String, Timer> entry : METRIC_REGISTRY.getTimers().entrySet()) { metrics.add(Metric.from(entry.getKey(), entry.getValue().getCount())); } return metrics; }
public static Meter meter(long count) { final Meter meter = mock(Meter.class); when(meter.getCount()).thenReturn(count); when(meter.getMeanRate()).thenReturn(2.0); when(meter.getOneMinuteRate()).thenReturn(3.0); when(meter.getFiveMinuteRate()).thenReturn(4.0); when(meter.getFifteenMinuteRate()).thenReturn(5.0); return meter; }
private void printMeter(Meter meter) { this.outputBufferPrintStream.printf(locale, " count = %d%n", meter.getCount()); this.outputBufferPrintStream.printf(locale, " mean rate = %2.2f events/%s%n", convertRate(meter.getMeanRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 1-minute rate = %2.2f events/%s%n", convertRate(meter.getOneMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 5-minute rate = %2.2f events/%s%n", convertRate(meter.getFiveMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 15-minute rate = %2.2f events/%s%n", convertRate(meter.getFifteenMinuteRate()), getRateUnit()); }
final Meter meter = meterEntry.getValue(); addMeter(builder, name, EMPTY_STRING, meter.getCount(), meter.getMeanRate(), meter.getOneMinuteRate(), meter.getFiveMinuteRate(), meter.getFifteenMinuteRate());
private void printMeter(Meter meter) { printIfEnabled(MetricAttribute.COUNT, String.format(locale, " count = %d", meter.getCount())); printIfEnabled(MetricAttribute.MEAN_RATE, String.format(locale, " mean rate = %2.2f events/%s", convertRate(meter.getMeanRate()), getRateUnit())); printIfEnabled(MetricAttribute.M1_RATE, String.format(locale, " 1-minute rate = %2.2f events/%s", convertRate(meter.getOneMinuteRate()), getRateUnit())); printIfEnabled(MetricAttribute.M5_RATE, String.format(locale, " 5-minute rate = %2.2f events/%s", convertRate(meter.getFiveMinuteRate()), getRateUnit())); printIfEnabled(MetricAttribute.M15_RATE, String.format(locale, " 15-minute rate = %2.2f events/%s", convertRate(meter.getFifteenMinuteRate()), getRateUnit())); }
@Override public Policy get(String resourceId) { try { ThrottlingPolicy throttlingPolicy = (ThrottlingPolicy) this.broker.getSharedResource(new ThrottlingPolicyFactory(), new SharedLimiterKey(resourceId)); Policy restliPolicy = new Policy(); restliPolicy.setPolicyName(throttlingPolicy.getClass().getSimpleName()); restliPolicy.setResource(resourceId); restliPolicy.setParameters(new StringMap(throttlingPolicy.getParameters())); restliPolicy.setPolicyDetails(throttlingPolicy.getDescription()); MetricContext resourceContext = (MetricContext) broker.getSharedResource(new MetricContextFactory(), new SubTaggedMetricContextKey(resourceId, ImmutableMap.of(RESOURCE_ID_TAG, resourceId))); StringMap metrics = new StringMap(); for (Map.Entry<String, Meter> meter : resourceContext.getMeters().entrySet()) { metrics.put(meter.getKey(), Double.toString(meter.getValue().getOneMinuteRate())); } restliPolicy.setMetrics(metrics); return restliPolicy; } catch (NotConfiguredException nce) { throw new RestLiServiceException(HttpStatus.S_404_NOT_FOUND, "Policy not found for resource " + resourceId); } } }
private void reportMeter(long timestamp, String name, Meter meter) { report(timestamp, name, "count,mean_rate,m1_rate,m5_rate,m15_rate,rate_unit", meterFormat, meter.getCount(), convertRate(meter.getMeanRate()), convertRate(meter.getOneMinuteRate()), convertRate(meter.getFiveMinuteRate()), convertRate(meter.getFifteenMinuteRate()), getRateUnit()); }
when(meter.getOneMinuteRate()).thenReturn(oneMinRate); when(meter.getFiveMinuteRate()).thenReturn(fiveMinRate); when(meter.getFifteenMinuteRate()).thenReturn(fifteenMinRate);
private void logMeter(String name, Meter meter) { loggerProxy.log(marker, "type={}, name={}, count={}, mean_rate={}, m1={}, m5={}, m15={}, rate_unit={}", "METER", prefix(name), meter.getCount(), convertRate(meter.getMeanRate()), convertRate(meter.getOneMinuteRate()), convertRate(meter.getFiveMinuteRate()), convertRate(meter.getFifteenMinuteRate()), getRateUnit()); }
private static <RESPONSE extends PaxosResponse> void cancelOutstandingRequestsAfterTimeout( List<Future<RESPONSE>> responseFutures) { boolean areAllRequestsComplete = Iterables.all(responseFutures, Future::isDone); if (areAllRequestsComplete) { return; } // give the remaining tasks some time to finish before interrupting them; this reduces overhead of // throwing exceptions CANCELLATION_EXECUTOR.schedule(() -> { for (Future<?> future : responseFutures) { boolean isCanceled = future.cancel(true); if (isCanceled) { cancelOutstandingRequestSuccess.mark(); } else { cancelOutstandingRequestNoOp.mark(); } } }, OUTSTANDING_REQUEST_CANCELLATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); if (log.isDebugEnabled() && shouldLogDiagnosticInformation()) { log.debug("Quorum checker canceled pending requests" + ". Rate of successful cancellations: {}, rate of no-op cancellations: {}", SafeArg.of("rateCancelled", cancelOutstandingRequestSuccess.getOneMinuteRate()), SafeArg.of("rateNoOpCancellation", cancelOutstandingRequestNoOp.getOneMinuteRate())); } }
log.info("Quorum checker executor rejected task", e); log.info("Rate of execution rejections: {}", SafeArg.of("rate1m", requestExecutionRejection.getOneMinuteRate()));
private void printMeter(Meter meter) { output.printf(locale, " count = %d%n", meter.getCount()); output.printf(locale, " mean rate = %2.2f events/%s%n", convertRate(meter.getMeanRate()), getRateUnit()); output.printf(locale, " 1-minute rate = %2.2f events/%s%n", convertRate(meter.getOneMinuteRate()), getRateUnit()); output.printf(locale, " 5-minute rate = %2.2f events/%s%n", convertRate(meter.getFiveMinuteRate()), getRateUnit()); output.printf(locale, " 15-minute rate = %2.2f events/%s%n", convertRate(meter.getFifteenMinuteRate()), getRateUnit()); }
private BsonDocument generateMeter(Meter meter) { BsonDocument document = new BsonDocument(); document.append("count", new BsonInt64(meter.getCount())); document.append("m15_rate", new BsonDouble(meter.getFifteenMinuteRate() * rateFactor)); document.append("m1_rate", new BsonDouble(meter.getOneMinuteRate() * rateFactor)); document.append("m5_rate", new BsonDouble(meter.getFiveMinuteRate() * rateFactor)); document.append("mean_rate", new BsonDouble(meter.getMeanRate() * rateFactor)); document.append("units", new BsonString("calls/" + singularRateUnitString)); return document; }