metrics-clojure icon indicating copy to clipboard operation
metrics-clojure copied to clipboard

Filtering metrics with Clojure functions

Open danielcompton opened this issue 8 years ago • 6 comments

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?

danielcompton avatar Jun 19 '16 21:06 danielcompton

You can either

  • Remove metrics and not collect them (so that they do not get recreated)
  • Develop a custom reporter (a Java interface implementation)

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 avatar Jun 19 '16 21:06 michaelklishin

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 avatar Jun 19 '16 21:06 michaelklishin

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

michaelklishin avatar Jun 21 '16 11:06 michaelklishin

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

danielcompton avatar Jun 21 '16 21:06 danielcompton

To functions that instantiate metric reporters.

michaelklishin avatar Jun 21 '16 21:06 michaelklishin

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

danielcompton avatar Jun 21 '16 21:06 danielcompton