go-metrics icon indicating copy to clipboard operation
go-metrics copied to clipboard

Rescale samples on reads too

Open ashrayjain opened this issue 6 years ago • 6 comments

Previously, we were only rescaling on updates. This meant that histograms would latch on to last updated values and stay at those values until the next update for a reader who reads the histogram periodically instead of decaying with time.

Fixes #215

ashrayjain avatar Jan 19 '19 14:01 ashrayjain

@rcrowley @mihasya

buffer51 avatar Jan 25 '19 08:01 buffer51

Friendly ping @rcrowley @mihasya

bmoylan avatar Feb 14 '19 17:02 bmoylan

This looks like a very good change, but it makes me wonder if folks have come to rely on the old behavior, and if changing this is a "backwards incompatible" change 🤔 Also trying to think of a case where this might cause a performance issue.. In a set up where you have lots of rarely updated counters that are read regularly, you could suddenly find yourself recomputing a bunch of EWMAs for things that were previously "free." Hmmm.

I do see a bunch of votes for this, and have definitely been annoyed by it in the past.

mihasya avatar Jul 04 '19 16:07 mihasya

I'm worried the fix is not complete - Snapshot() is a read, so it needs rescaling, too. Otherwise, the reads performed on a Snapshoted metric will not trigger the rescaling.

If it seems out of scope of this MR, I could create another one. @ashrayjain, @mihasya what do you folks think about it?

p-kozlowski avatar Oct 22 '19 10:10 p-kozlowski

any news on this ?

schmurfy avatar May 14 '20 12:05 schmurfy

@p-kozlowski you are correct. I have updated this to also rescale on Snapshot()

ashrayjain avatar May 20 '20 14:05 ashrayjain