- (use [metrics.utils :only (metric-name get-percentiles)])

- (import (com.yammer.metrics Metrics))

- (import (com.yammer.metrics.core Histogram MetricName)))

+ (:use [metrics.utils :only (metric-name get-percentiles)])

+ (:import (com.yammer.metrics Metrics))

+ (:import (com.yammer.metrics.core Histogram MetricName)))

; Create ----------------------------------------------------------------------

+ "Create and return a Histogram metric with the given title.

+ By default a biased Histogram is created. This is probably what you want, but

+ if you know what you're doing you can pass false to create a uniform one

([title] (histogram title true))

; Read ------------------------------------------------------------------------

-(defn mean [^Histogram h]

+ "Return the mean value of the given Histogram."

-(defn std-dev [^Histogram h]

+ "Return the standard deviation of the given Histogram."

+ "Return a mapping of percentiles to their values for the given Histogram.

+ (percentiles myhistogram [0.5 0.9 1.0])

+ ;=> {0.5 200, 0.9 240, 1.0 500}

+ * 50% of the values recorded by this Histogram were less than or equal to 200

+ * 90% were less than or equal to 240

+ * 100% were less than or equal to 500

+ If you don't pass a list of desired percentiles, the default will be

+ [0.75 0.95 0.99 0.999 1.0]."

(percentiles h [0.75 0.95 0.99 0.999 1.0]))

-(defn number-recorded [^Histogram h]

+ "Return the number of values recorded by the given Histogram."

-(defn largest [^Histogram h]

+ "Return the largest value recorded by the given Histogram."

-(defn smallest [^Histogram h]

+ "Return the smallest value recorded by the given Histogram."

-(defn sample [^Histogram h]

+ "Return the values in the given Histogram's current sampling.

+ This is almost certainly NOT what you want. Read up on how these histograms

+ work and make sure you understand it before using this function."

(.getValues (.getSnapshot h)))

; Write -----------------------------------------------------------------------

-(defn update! [^Histogram h n]

+ "Record a value in the given Histogram."

-(defn clear! [^Histogram h]

+ "Clear all data from the given Histogram."