Recognos / 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.
Apache License 2.0
639 stars 110 forks source link

Facility for metrics which 'come and go' #73

Closed alex-davidson closed 7 years ago

alex-davidson commented 7 years ago

I've been trying to figure out how to hook into the data provider to do this, but can't quite see where to make it fit, so...

Use case: report on available disk space using WMI queries. Entire Metrics set is dumped to JSON periodically. Problem: Each disk needs its own gauge, but the disks attached to the system may change over time. If a disk is removed, its gauge should be removed (absence of the metric vs. zero value is a significant difference)

What's the recommended way of approaching this with the Metrics.NET public API? Or should I look at building support for WMI queries and transient metrics directly against Metrics.NET's internals and submit a pull request?

alex-davidson commented 7 years ago

I think I've found what I was looking for in the form of AdvancedMetricsContext#AttachContext. It means implementing an entire MetricsContext, but mine's read-only and doesn't need to support the methods which add Counters, etc.