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

Q: How do I get the reports created on application shutdown?

mattiasw2 opened this issue · comments

The web interface is really nice, but it would be nice to get the reports automatically at end of execution. Is there some kind of hook for this?

@mattiasw2 I'm not sure if this is what you mean by "get the reports", but you can manually run a report by using something like this:

var data = Metric.Context(string.Empty).DataProvider.CurrentMetricsData; 
new ConsoleReport().RunReport(data, () => HealthChecks.GetStatus(), CancellationToken.None);
new StringReport().RunReport(data, () => HealthChecks.GetStatus(), CancellationToken.None);

Closing this for now, let me know if you need more info.

Yes, that was what I was looking for. Thanks!