clj-commons / metrics-clojure

A thin façade around Coda Hale's metrics library.
http://metrics-clojure.rtfd.org/
MIT License
342 stars 82 forks source link

Filtering metrics with Clojure functions #105

Open danielcompton opened 8 years ago

danielcompton commented 8 years ago

We're using Hosted Graphite (great service btw), and we are charged by our metric count. We have ring metrics, JVM metrics, and custom metrics and are going over our cap. I'd like to filter some of the ring metrics as we only need a few from here, but it's not clear if/how to do that? I read the docs on removing metrics, but it seemed like they would just be recreated later.

What's the recommended way of filtering the metrics that get sent to a (graphite) reporter?

michaelklishin commented 8 years ago

You can either

I'm not aware of a way to filter out metrics in reporters other than duplicating the entire metric registry and removing some keys right before sending the data.

michaelklishin commented 8 years ago

By the way, I am open to ideas about how to address this but I'm afraid this specific library is largely at the mercy of a feature provided in Dropwizard Metrics. Unless we want to subclass every single reporter, at least.

michaelklishin commented 8 years ago

Actually, there is MetricFilter which can be passed in but there is no way to define one as a Clojure function.

danielcompton commented 8 years ago

When you say "passed in", where is it passed?

michaelklishin commented 8 years ago

To functions that instantiate metric reporters.

danielcompton commented 8 years ago

Awesome, I'll take a look at this. If it works well, I'll put together a PR to make it more Clojure native.