Created
October 26, 2017 16:24
-
-
Save halgari/71dd5cfd8234a982a11e48d2aac003b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def ^:dynamic *counters*) | |
(defn new-counter [name] | |
"Creates a pair of LongAdders" | |
...) | |
(defn get-counter [name] | |
(if-let [ctr (get *counter* name] | |
ctr | |
(let [c (new-counter name) | |
(set! *counters* (assoc *counters* c)) | |
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