Allow using negative values in RangeSampler#increment and RangeSampler#decrement#532
Conversation
|
Hey @jcazevedo! Thanks for the PR :)... Just wanted to ask, what was the use case where allowing negative numbers was necessary? |
|
It's mostly an API convenience. I have a situation where I'm keeping track of deltas with a min max counter and I'm currently doing: if (delta >= 0) metric.increment(delta)
else metric.decrement(-1 * delta)If the |
|
Seems like a nice thing to have, thanks for sharing! Although, I think it would be better to add a new method to the RangeSampler API, lets say If we go that way we keep the increment/decrement with the same cost as before (only updating two places) and only incur in the additional expense when it is actually needed. What do you think about that? Also, what does @dpsoft think about this change? |
|
I'd be fine with the |
This pull request modifies the
incrementanddecrementmethods ofRangeSamplerso that they correctly track the minimum and maximum values if they're supplied with negative values.