fralalonde / dipstick

Configurable metrics toolkit for Rust applications
Apache License 2.0
99 stars 9 forks source link

Impossible removal of observed metrics, resource leaks #64

Closed mixalturek closed 5 years ago

mixalturek commented 5 years ago

Re-registration of a new metric under already used name lets all of them active. If a metric is registered periodically or on an recurring action this behavior will result in kinda resource leak. Metrics that are once added can't be removed nor unregistered, the API doesn't support that.

Code to reproduce, using dipstick/examples/observer.rs:

    metrics.observe(metrics.gauge("uptime"), |_| 5).on_flush();
    metrics.observe(metrics.gauge("uptime"), |_| 3).on_flush();
    metrics.observe(metrics.gauge("uptime"), |_| 10).on_flush();

Value 6 that has never existed and that is based on average is then reported forever.

process.heartbeat 1
process.threads 4
process.uptime 6
process.heartbeat 1
process.threads 4
process.uptime 6
process.heartbeat 1
process.threads 4
process.uptime 6
...

I prefer a behavior similar to this one - replace the existing metric by a new one. https://github.com/fralalonde/dipstick/commit/5e35e680b7c690bdc3d87b89107ee4bbe4be3283

fralalonde commented 5 years ago

Please have a look at #66