Skip to content

Commit

Permalink
Merge pull request #117 from felixbarny/patch-1
Browse files Browse the repository at this point in the history
Remove sum from Summary
  • Loading branch information
brian-brazil authored Aug 10, 2016
2 parents fc5b534 + c72bbf8 commit e9e5395
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,14 @@ List<MetricFamilySamples> fromGauge(String name, Gauge gauge) {
*
*/
List<MetricFamilySamples> fromSnapshotAndCount(String name, Snapshot snapshot, long count, double factor, String helpMessage) {
long sum = 0;
for (long i : snapshot.getValues()) {
sum += i;
}
List<MetricFamilySamples.Sample> samples = Arrays.asList(
new MetricFamilySamples.Sample(name, Arrays.asList("quantile"), Arrays.asList("0.5"), snapshot.getMedian() * factor),
new MetricFamilySamples.Sample(name, Arrays.asList("quantile"), Arrays.asList("0.75"), snapshot.get75thPercentile() * factor),
new MetricFamilySamples.Sample(name, Arrays.asList("quantile"), Arrays.asList("0.95"), snapshot.get95thPercentile() * factor),
new MetricFamilySamples.Sample(name, Arrays.asList("quantile"), Arrays.asList("0.98"), snapshot.get98thPercentile() * factor),
new MetricFamilySamples.Sample(name, Arrays.asList("quantile"), Arrays.asList("0.99"), snapshot.get99thPercentile() * factor),
new MetricFamilySamples.Sample(name, Arrays.asList("quantile"), Arrays.asList("0.999"), snapshot.get999thPercentile() * factor),
new MetricFamilySamples.Sample(name + "_count", new ArrayList<String>(), new ArrayList<String>(), count),
new MetricFamilySamples.Sample(name + "_sum", new ArrayList<String>(), new ArrayList<String>(), sum * factor)
new MetricFamilySamples.Sample(name + "_count", new ArrayList<String>(), new ArrayList<String>(), count)
);
return Arrays.asList(
new MetricFamilySamples(name, Type.SUMMARY, helpMessage, samples)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public void testHistogram() throws IOException {
i += 1;
}
assertEquals(new Double(100), registry.getSampleValue("hist_count"));
assertEquals(new Double(4950), registry.getSampleValue("hist_sum"));
for (double b : Arrays.asList(0.75, 0.95, 0.98, 0.99)) {
assertEquals(new Double((b - 0.01) * 100), registry.getSampleValue("hist",
new String[]{"quantile"}, new String[]{String.format("%.2f", b)}));
Expand All @@ -137,7 +136,6 @@ public void testTimer() throws IOException, InterruptedException {
// We slept for 1Ms so we ensure that all timers are above 1ms:
assertTrue(registry.getSampleValue("timer", new String[]{"quantile"}, new String[]{"0.99"}) > 0.001);
assertEquals(new Double(1.0D), registry.getSampleValue("timer_count"));
assertRegistryContainsMetrics("timer_count", "timer_sum");
}

@Test
Expand Down

0 comments on commit e9e5395

Please sign in to comment.