Source

metrics-clojure / src / metrics / gauges.clj

Steve Losh caf4e68 
Steve Losh 33deb3b 


Steve Losh caf4e68 

Steve Losh aa3e7bf 


Steve Losh 33deb3b 
Steve Losh caf4e68 

Steve Losh 33deb3b 
Steve Losh aa3e7bf 
Steve Losh caf4e68 

Steve Losh 33deb3b 
Steve Losh caf4e68 

Steve Losh aa3e7bf 
Steve Losh d3a7c66 
Steve Losh 33deb3b 
Steve Losh aa3e7bf 
(ns metrics.gauges
  (:use [metrics.utils :only (metric-name)])
  (:import (com.yammer.metrics Metrics))
  (:import (com.yammer.metrics.core Gauge)))


; Create ----------------------------------------------------------------------
(defmacro gauge [title & body]
  `(Metrics/newGauge (metric-name ~title)
                     (proxy [Gauge] []
                       (value [] (do ~@body)))))


; Read ------------------------------------------------------------------------
(defn gauge-fn [title f]
  (Metrics/newGauge (metric-name title)
                    (proxy [Gauge] []
                      (value [] (f)))))


; Read ------------------------------------------------------------------------
(defn value [^Gauge g]
  (.value g))