Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(def ^:dynamic *counters*)
(defn new-counter [name]
"Creates a pair of LongAdders"
(defn get-counter [name]
(if-let [ctr (get *counter* name]
(let [c (new-counter name)
(set! *counters* (assoc *counters* c))
(defn record-value [k v]
(record-counter (get-counter k) v))
; ^^ Part of our existing metrics library
(defn on-event
[k v]
(when *counters*
(record-value k v)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.