etishor / Metrics.NET

The Metrics.NET library provides a way of instrumenting applications with custom metrics (timers, histograms, counters etc) that can be reported in various ways and can provide insights on what is happening inside a running application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Providing custom MetricsDataProvider to MetricsHttpListener

shay1e opened this issue · comments

Hi,

MetricsHttpListener is very useful. We're using it to expose each machine's metrics to an external aggregation service, which stores all the metrics in a database (so we could query them later).
The way we use it is just calling the static Metric.Config.WithHttpEndpoint(string) method, which initializes a new MetricsHttpListener instance with the default static MetricsConfig and DefaultMetricsContext instances. As a result, every HTTP request is responded with all the gauges available, although we only need our custom metrics.
I tried to figure out from the source code how to achieve the desired outcome, but in vain. Is this even possible? If not, I'd be glad to contribute. If yes, then how?

On the dev branch (and latest prerelease nuget) you can pass a MetricsFilter to the config call.

I'll look at it again tomorrow, but let me know if you think it can be improved.

Thank you for your reply. I looked at the code, and it seems exactly what we needed :)