public static Map<String, Long> dumpMetrics(MetricContext context) { Map<String, Long> output = new HashMap<>(); for (Map.Entry<String, Meter> entry : context.getMeters().entrySet()) { output.put(entry.getKey(), entry.getValue().getCount()); } for (Map.Entry<String, Timer> entry : context.getTimers().entrySet()) { output.put(entry.getKey(), entry.getValue().getCount()); } return output; }
@Override public void report() { if (this.filter.isPresent()) { report(this.context.getGauges(this.filter.get()), this.context.getCounters(this.filter.get()), this.context.getHistograms(this.filter.get()), this.context.getMeters(this.filter.get()), this.context.getTimers(this.filter.get())); } else { report(this.context.getGauges(), this.context.getCounters(), this.context.getHistograms(), this.context.getMeters(), this.context.getTimers()); } }
@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); } } }
for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric();
for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : taskMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric();