Preventing metrics on certain handlers

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Preventing metrics on certain handlers

gschrader
The Paj4Module includes username/password which I don't want to be captured but I also have a rest api that certain endpoints I want to skip as well.

I'm not sure how feasible this is or I would be better off rolling my own handler like RequestTimingHandler?  I guess another advantage of rolling my own is I'd have control over the timer name as I'd like to change that a bit too.
rus
Reply | Threaded
Open this post in threaded view
|

Re: Preventing metrics on certain handlers

rus
The way to achieve this is to use a filter.  All the metrics still get captured but at a reporter level you can filter out what you don't want to be reported.  If you don't provide a filter to Metrics it defaults to MetricFilter.ALL  Check out com.codahale.metrics.ConsoleReporter#Builder as an example.

This is on my list to do, although I don't think I have an issue created that captures this.  If you'd like to help and contribute this functionality that would be awesome :)

WRT the timer name, what did you want to change it to?  Maybe we can make that more configurable too.  Happy to get as much feedback as possible on the Metrics module before we go 1.0 from people who are actually using it.
Reply | Threaded
Open this post in threaded view
|

Re: Preventing metrics on certain handlers

gschrader
For sure I would like to be able to contribute.  Looks like a filter would do the trick.  So ideally one would be able to provide the builder (for each of the reporters) when creating the CodaHaleMetricsModule instance however looks like that would be tricky because of the private constructor of the builder classes (i.e. needing to call the forRegistry method).

For the timer name I'm not convinced I want the query string as part of the name.
rus
Reply | Threaded
Open this post in threaded view
|

Re: Preventing metrics on certain handlers

rus
That's great!  Do you mind creating an issue and we can move the implementation disucssion there?

I don't think we need to supply the builder though.  One way would be to create our own MetricFilter implementation that takes a regular expression.  And allow users to set a filter regex on the reporter Config objects e.g. ratpack.codahale.metrics.CodaHaleMetricsModule#Console.  So using external config you could set metrics.console.filter=<<your regex here>>
Reply | Threaded
Open this post in threaded view
|

Re: Preventing metrics on certain handlers

gschrader