Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit ab57486

Browse files
author
Vicent Marti
committed
Merge pull request #11 from github/vmg/empty-histo
histogram: Do not report samples if our period is empty
2 parents 15e00f1 + 240cb3e commit ab57486

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/metric.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ histogram__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void
177177
key = alloca(metric->key_len + strlen(".percentile.999") + 1);
178178
memcpy(key, metric->key, metric->key_len);
179179

180+
181+
WITH_SUFFIX(".count") {
182+
sample(key, hsample.count, opaque);
183+
}
184+
185+
/* if there have been no metrics during this sampling period,
186+
* we don't need to report any of the histogram samples */
187+
if (hsample.count == 0.0)
188+
return;
189+
180190
WITH_SUFFIX(".min") {
181191
sample(key, hsample.min, opaque);
182192
}
@@ -193,10 +203,6 @@ histogram__sample(struct brubeck_metric *metric, brubeck_sample_cb sample, void
193203
sample(key, hsample.mean, opaque);
194204
}
195205

196-
WITH_SUFFIX(".count") {
197-
sample(key, hsample.count, opaque);
198-
}
199-
200206
WITH_SUFFIX(".median") {
201207
sample(key, hsample.median, opaque);
202208
}

0 commit comments

Comments
 (0)