Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't Reset BucketHistograms from the MetricsRoot object #744

Open
zcassels3 opened this issue Sep 29, 2022 · 0 comments
Open

Can't Reset BucketHistograms from the MetricsRoot object #744

zcassels3 opened this issue Sep 29, 2022 · 0 comments

Comments

@zcassels3
Copy link

The DefaultMetricsProvider accessible from MetricsRoot doesn't expose HistogramBuckets. This prevents the 'Reset()' operation to be used for HistogramBuckets much like the other metric types.

https://github.com/AppMetrics/AppMetrics/blob/main/src/Core/src/App.Metrics.Core/Internal/DefaultMetricsProvider.cs
.. doesn't have HistogramBuckets

Here is an example of a gauge being updated then reset. The measurement options are exposed using the Measure property and the 'Reset()' function is exposed through the provider.

var _gaugeOptions = new App.Metrics.Gauge.GaugeOptions
{
    Context = 'app',
    Name = 'my_gauge'
};
_root.Measure.Gauge.SetValue(_gaugeOptions, 10);
...
_root.Provider.Gauge.Instance(_gaugeOptions).Reset();

In the example of the BucketHistogram, the provider doesn't have an option to reset the object in the registry.

var histogramOptions = new App.Metrics.BucketHistogram.BucketHistogramOptions
{
    Context = 'app',
    Name = 'my_histogram',
    Buckets = new List<double> { 1, 10, 100, 1000, 2000, 5000 }
};
_root.Measure.BucketHistogram.Update(_histogramOptions, 100);
_root.Measure.BucketHistogram.Update(_histogramOptions, 5555);
...
// this option doesn't exist!
_root.Provider.BucketHistogram.Instance(_histogramOptions).Reset();

The IBucketHistogram is a IResetableMetric so it seems like this should be a legal operation.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant