On Jan 20, 2016, at 6:17 AM, Benson Margulies <
ben...@basistech.com> wrote:
>
> I'd like to use a Histogram to implement some adaptive behavior. The question I want to ask is, what's the mean over the last minute? The javadoc for 'Snapshot' doesn't seem to tell me: is that going to be since the beginning of time or since the last snapshot? Or something else?
This isn’t really well-defined right now. Different tools want it done different ways, and metrics tries to play nice, but we don’t have API to express the differences very well (yet).
In my custom reservoir backed by hdrhistogram (
https://bitbucket.org/marshallpierce/hdrhistogram-metrics-reservoir) there’s another reservoir impl that resets its state every time you ask for a snapshot for exactly uses like this. This will give you the behavior you want: get a snapshot once per minute and it will include only the last minute’s data.
As a side note, be sure that the thing you’re measuring has a mean that’s useful (i.e. is normally distributed). Latency generally is not normal, so the mean isn’t very useful.