             [clojure.string :as str]
             [environ.core :refer [env]]
             [metrics.jvm.core :refer [instrument-jvm]]
-            [metrics.reporters.graphite :refer [reporter]])
+            [metrics.reporters.graphite :as graphite])
   (:import [java.io Reader]
            [java.net InetAddress UnknownHostException]
            [java.util Properties]

(def ^:dynamic graphite-port
  (Integer/valueOf (env :graphite-port "2003")))

(def ^:dynamic graphite-post-interval
  (Integer/valueOf (env :graphite-post-interval "60")))

(def ^:dynamic graphite-post-unit
  (TimeUnit/valueOf (env :graphite-post-unit "SECONDS")))

(def ^:dynamic graphite-prefix
  (env :graphite-prefix))

(defn start-graphite-reporting
  [& [options]]
  (instrument-jvm)
  (let [{:keys [graphite-enabled? graphite-host graphite-port
                graphite-post-interval-seconds graphite-prefix]} (merge graphite-defaults options)
        graphite-reporter (graphite/reporter {:host graphite-host
                                              :port graphite-port
                                              :prefix graphite-prefix})]
    (when graphite-enabled?
      (graphite/start graphite-reporter graphite-post-interval-seconds))))

(def version
  (memoize
