 
 (def calls
   {:lifecycle/before-task-start before-task})
-

  (:import [java.util.concurrent TimeUnit]
           [java.util.concurrent.atomic AtomicLong]
           [com.codahale.metrics Gauge]))

(defprotocol IGauge
  (setGauge [this value]))

(deftype OGauge [value]
  IGauge
  (setGauge [this new-value]
    (.set ^AtomicLong value ^long new-value))
  Gauge
  (getValue [this]
    (.get ^AtomicLong value)))

;(def v (->OGauge (AtomicLong.)))
;(setGauge v 9933)
;(.getValue v)

(defn new-lifecycle-latency [reg tag lifecycle]
  (let [timer ^com.codahale.metrics.Timer (t/timer reg (into tag ["task-lifecycle" (name lifecycle)]))] 

                                    0
                                    (:tree (:onyx.core/results (task/get-event state)))))))))

(defn update-rv-epoch [^AtomicLong replica-version ^AtomicLong epoch epoch-rate]
  (fn [state latency-ns]
    (m/mark! epoch-rate 1)
    (.set ^AtomicLong replica-version (task/replica-version state))
    (.set ^AtomicLong epoch (task/epoch state))))

;; FIXME, close counters and remove them from the registry
(defn before-task [{:keys [onyx.core/job-id onyx.core/id onyx.core/monitoring
