Added custom reservoir support #104

Merged
merged 1 commit into from May 27, 2016

Projects

None yet

2 participants

@sunng87
Contributor
sunng87 commented May 27, 2016

Reservoir as an important feature is missing in current metrics-clojure. It allows histogram based metrics (histogram and timer) to drop some data based on custom strategy (uniform, sliding window, etc). This is helpful when we want to collect timer for last minute, for example.

The bad part is upstream API doesn't provide entry point for custom reservoir in MetricRegistry, so there is no way to use this feature with MetricRegistry's get-or-add API. Duplicated creation will lead to IllegalArgumentException. So I created new function for timer and histogram.

@michaelklishin @sjl PTAL

@michaelklishin michaelklishin commented on an outdated diff May 27, 2016
metrics-clojure-core/src/metrics/core.clj
@@ -83,3 +86,28 @@
"Returns a map of all the counters in the registry and their names."
[^MetricRegistry reg]
(.getCounters reg))
+
+(defn uniform-reservior
+ "Create a uniform reservior, which uses Vitter's Algorithm R to
+ produce a statistically representative sample. Default size: 1028."
+ ([] (UniformReservoir.))
@michaelklishin
michaelklishin May 27, 2016 Collaborator

Sorry to nitpick but can we keep the argument vector and function body on separate lines, here and everywhere else?

@sunng87 sunng87 (feat) added custom reservoir support
Signed-off-by: Ning Sun <sunng@about.me>
584b4ed
@sunng87
Contributor
sunng87 commented May 27, 2016

@michaelklishin Thanks for fast response. I just updated the style.

@michaelklishin michaelklishin self-assigned this May 27, 2016
@michaelklishin michaelklishin merged commit 04cf684 into sjl:master May 27, 2016
@michaelklishin
Collaborator

Thank you!

@sunng87 sunng87 deleted the unknown repository branch May 27, 2016
@sunng87
Contributor
sunng87 commented May 27, 2016

@michaelklishin possible to make a release for this?

@michaelklishin
Collaborator

@sunng87 I'll try making one over the weekend.

@michaelklishin
Collaborator

@sunng87 2.7.0 is up on Clojars.

@sunng87
Contributor
sunng87 commented Jun 1, 2016

@michaelklishin Excellent! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment