Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View timer.clj
1 2 3 4 5 6 7
(defn find-timer [timer-name]
(timers/timer ["APPNAME" "timer" (name timer-name)]))
 
(defmacro with-timer [timer-name & body]
`(let [timer# (find-timer ~timer-name)]
(timers/time! timer#
(do ~@body))))
clifton commented

On our diversion onto metrics last night, we forgot to circle back to look at the timer. Here's slightly modified version: https://gist.github.com/orb/d207...­

This basically wraps a named timer which (through code not shown here) creates a timer metric and queues it to be sent to Riemann. There's nothing magical here except the point I was making about being able to nREPL to the server. If we are trying to live-debug a performance issue, I can connect to the server and wrap the code I'm interested in a with-timer. We'll immediately get live metrics into Riemann and then into elastic search for those pretty charts I showed in kibana. When we're done, I can remove the with-timer.

I find this brilliant. It doesn't require making a lot of toggle-able metrics in advance. It doesn't require any tooling fancier than nREPL. And, it doesn't require any server downtime.

clifton commented

Awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.