Build Status

A Metrics Reservoir implementation backed by HdrHistogram.

The artifacts are published to Bintray. If you're using gradle, use the jcenter() repository and put this in your build.gradle dependencies block: compile 'org.mpierce.metrics.reservoir:hdrhistogram-metrics-reservoir:THE_LATEST_RELEASED_VERSION'

Or, if you're on Maven, see the Set Me Up button at and then add the dependency.

Then, use the following reservoir implementations when you create your Histogram or Timer instances:

  • HdrHistogramReservoir, a reservoir that accumulates its internal state forever
  • HdrHistogramResetOnSnapshotReservoir, a reservoir that resets its internal state on each snapshot (which is how reporters get information from reservoirs). See this article for when that is useful.

See for why you want HdrHistogram as the underlying data structure, or watch Gil Tene talking about how latency is hard to measure well, or read this thread. The short version:

  • It's very fast (tens of nanoseconds to record)
  • It won't lose the outliers, which are the measurements you care about since latency is most assuredly not normally distributed
  • It doesn't allocate (except for the occasional resize, or you can pre-size your histograms to not allocate at all)

Also, check out some simple benchmarks of the various reservoir implementations.