 
 (defn- start []
   (log/info "-> starting telemetry")
-  (let [config     (config/config config/configuration [:telemetry])
-        queue      (chan (sliding-buffer (:queue-size config 1000)))
-        killswitch (chan)
-        client     (when (:riemann config) (riemann/tcp-client (:riemann config)))]
+  (let [config      (config/config config/configuration [:telemetry])
+        riemann-cfg (:riemann config)
+        queue       (chan (sliding-buffer (:queue-size config 1000)))
+        killswitch  (chan)
+        client      (when (:host riemann-cfg) (riemann/tcp-client riemann-cfg))]
     (worker killswitch client queue (:interval config 30))
     {:host       (:host config (localhost))
      :r-client   client

            [gorillalabs.tesla.component.configuration :as config]
            [mount.core :as mnt]
            [riemann.client :as riemann])
  (:import (java.net InetAddress)))

(defn- now []
  (/ (System/currentTimeMillis) 1000))

(defn- stop [telemetry]
  (log/info "<- stopping telemetry")
  (close! (:killswitch telemetry))
  (flush telemetry)
  (when-let [client (:r-client telemetry)]
    (riemann/close! client)))

(mnt/defstate telemetry
