 ;; some cases if care is not taken.
 
 (defrecord MeteredBlockStore
-  [store label record-event]
+  [store label recording-fn]
 
   store/BlockStore
 



(defn metered-block-store
  "Creates a new metered block store. The `record-event` function will be
  called once for each measurement, with the meter store record and a map
  containing the metric name string, a numeric value, and possibly other data."
  [record-event & {:as opts}]
  (when-not (fn? record-event)
    (throw (IllegalArgumentException.
             (str "First argument must be a metric recording function: "
                  (pr-str record-event)))))
  (map->MeteredBlockStore
    (assoc opts :record-event record-event)))

      ProxyOutputStream)))


(def ^:dynamic *meter-store*
  "Thread-bound inner metering store to report events up to."
  nil)


(defn- meter-label
  "Construct a string to label the metered store."
  [store]
  (or (:label store) (.getSimpleName (class (:store store)))))


(defn record-metric!
  "Record a metric to the current thread-bound meter store. Does nothing if no
  store is bound."
  [metric-type value & {:as attrs}]
  {:pre [(qualified-keyword? metric-type) (number? value)]}
  (when-let [store *meter-store*]
    (let [event (assoc attrs :type metric-type :value value)
          record! (:record-fn store)]
      (record! store event)))
  nil)



;; ## Stream Metering
