To prevent that, we would need to make sure we create a sample only if a histogram is not present. At present, I am doing this with a mutex protected dict, but this is annoying.
Can we turn this function into accepting a Sample generator callback instead?
type NewSampleFunc func() Sample
// GetOrRegisterHistogramWithSampleFunc(name string,
// r Registry,
// s NewSampleFunc) Histogram
metrics.GetOrRegisterHistogramWithSampleFunc(metricName,
metricsRegistry,
func(){return NewUniformSample(size)}).Inc(amount)
I usually use counters, gauges and timers in code somewhat like this:
But doing the same thing with Histograms are a problem. This is the call signature.
If I want to use an UniformSample, am I supposed to use it like this?
But that would create a new sample on every call.
To prevent that, we would need to make sure we create a sample only if a histogram is not present. At present, I am doing this with a mutex protected dict, but this is annoying.
Can we turn this function into accepting a Sample generator callback instead?