Source

metrics-clojure / src / metrics / gauges.clj

Steve Losh caf4e68 





Steve Losh aa3e7bf 


Steve Losh caf4e68 


Steve Losh aa3e7bf 
Steve Losh caf4e68 




Steve Losh aa3e7bf 


(ns metrics.gauges
  (use [metrics.utils :only (metric-name)])
  (import (com.yammer.metrics Metrics))
  (import (com.yammer.metrics.core GaugeMetric)))


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

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


; Write -----------------------------------------------------------------------
(defn value [^GaugeMetric g]
  (.value g))