 (defmacro ^:private measure-method
   "Anaphoric macro to wrap a form in metric recording."
   [[method-kw args] & body]
-  `(let [elapsed# (stopwatch)]
+  `(let [label# (meter-label ~'this)
+         elapsed# (stopwatch)]
      (try
-       ; TODO: bind dynamic context
-       ~@body
+       (binding [*meter-store* ~'this]
+         ~@body)
        (finally
          (log/tracef "Method %s of %s block store on %s took %.1f ms"
                      (name ~method-kw)
-                     ~'label
+                     label#
                      ~args
                      @elapsed#)
-         (~'record-event
+         (~'recording-fn
            ~'this
            {:type ::method-time
-            :label ~'label
+            :label label#
             :method ~method-kw
             :value @elapsed#})))))
 

      ProxyOutputStream)))


; TODO: dynamic context var


;; ## Stream Metering

;; some cases if care is not taken.

(defrecord MeteredBlockStore
  [store label recording-fn]

  store/BlockStore

