metrics-clojure / src / metrics / histograms.clj

Diff from to


 (ns metrics.histograms
-  (use [metrics.utils :only (metric-name)])
+  (use [metrics.utils :only (metric-name get-percentiles)])
   (import (com.yammer.metrics Metrics))
-  (import (com.yammer.metrics.core HistogramMetric)))
+  (import (com.yammer.metrics.core Histogram MetricName)))
 ; Create ----------------------------------------------------------------------
 (defn histogram
   ([title] (histogram title true))
   ([title biased]
-   (Metrics/newHistogram (metric-name title) biased)))
+   (Metrics/newHistogram
+     ^MetricName (metric-name title)
+     (boolean biased))))
 ; Read ------------------------------------------------------------------------
-(defn mean [^HistogramMetric h]
+(defn mean [^Histogram h]
   (.mean h))
-(defn std-dev [^HistogramMetric h]
+(defn std-dev [^Histogram h]
   (.stdDev h))
 (defn percentiles
-  ([^HistogramMetric h]
+  ([^Histogram h]
    (percentiles h [0.75 0.95 0.99 0.999 1.0]))
-  ([^HistogramMetric h ps]
-   (zipmap ps
-           (.percentiles h (double-array ps)))))
+  ([^Histogram h ps]
+   (get-percentiles h ps)))
-(defn number-recorded [^HistogramMetric h]
+(defn number-recorded [^Histogram h]
   (.count h))
-(defn largest [^HistogramMetric h]
+(defn largest [^Histogram h]
   (.max h))
-(defn smallest [^HistogramMetric h]
+(defn smallest [^Histogram h]
   (.min h))
-(defn sample [^HistogramMetric h]
-  (.values h))
+(defn sample [^Histogram h]
+  (.getValues (.getSnapshot h)))
 ; Write -----------------------------------------------------------------------
-(defn update! [^HistogramMetric h n]
+(defn update! [^Histogram h n]
   (.update h (long n))
-(defn clear! [^HistogramMetric h]
+(defn clear! [^Histogram h]
   (.clear h)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.