expose org.HdrHistogram.Histogram object via HistogramSnapshot

Issue #10 new
Stan Rosenberg created an issue

It's extremely useful to generate additional metrics per histogram bucket, e.g., its cardinality. Since HistogramSnapshot currently doesn't expose org.HdrHistogram.Histogram, we must resort to using reflection. Our current workaround is to check if snapshot.getClass.getName is equal to "org.mpierce.metrics.reservoir.hdrhistogram.HistogramSnapshot", in which case we get "histogram" field via reflection and use "getCountBetweenValues" to compute the cardinality of a corresponding bucket.

Comments (2)

  1. Marshall Pierce repo owner

    That does sound useful, but IIRC it's not safe to do that because the histogram could be re-used by the time you get around to inspecting it. I'll have to look more closely to see what can be done.

  2. Stan Rosenberg reporter

    It's completely safe in our use-case because the histogram encapsulated by HistogramSnapshot is immutable. That is, when (dropwizard) metrics exporter thread is scheduled it will invoke HdrHistogramReservoir.getSnapshot which is what we use to extract buckets and their cardinalities. I am happy to share a code snippet if that helps clarify the use-case.

  3. Log in to comment