 ;; Measure is a library that enables Clojure programs to track critical aspects of
 ;; their behavior.  Using idiomatic wrappers around Coda Hale's excellent
 ;; [Metrics][http://metrics.codahale.com] library, one can measure statistics from
-;; simple counters to
-;; exponentially-decaying histograms.
-;;
-;; 
+;; simple counters to exponentially-decaying histograms.
 
 (ns measure.core
   {}


;; The core construct of measure is the registry.  To be useful, all
;; metrics are registered with a registry, which is typically a singleton.
;; 
;;

(defn registry
  "Creates and returns a new metrics registry."

  Timer
  (value [t] (.getCount t)))

;; Some metrics (histograms, meters, and timers) provide non-scalar information, and `value` is
;; insufficient for these types.  Meters expose rates, histograms expose distribution snapshots,
;; and timers expose both.

(defn rates
  "Gets the current rate of events for the given measurement."
  [^Metered meter-or-timer]
  {:count (.getCount meter-or-timer)
   :15-minute-rate (.getFifteenMinuteRate meter-or-timer)
   :5-minute-rate (.getFiveMinuteRate meter-or-timer)
   :1-minute-rate (.getOneMinuteRate meter-or-timer)
   :mean-rate (.getMeanRate meter-or-timer)})

(defn snapshot
  "Gets a snapshot of the current distribution for the given measurement."
  [^Sampling histogram-or-timer]
  (let [s (.getSnapshot histogram-or-timer)]
    {:size (.size s)
     :min (.getMin s)
     :max (.getMax s)
