Skip to content

Commit

Permalink
Adds enabled toggle to tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
roobalimsab committed Sep 26, 2019
1 parent bc487c8 commit a0f425f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion resources/config.test.ci.edn
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
:channels {:channel-1 {:worker-count [10 :int]
:retry {:count [5 :int]
:enabled [true :bool]}}}}}
:tracer {:jaeger_service_name "test_service"
:tracer {:enabled [true :bool]
:jaeger_service_name "test_service"
:jaeger_endpoint "test_endpoint"
:jaeger_reporter_log_spans [true :bool]}}}

3 changes: 2 additions & 1 deletion resources/config.test.edn
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
:channels {:channel-1 {:worker-count [10 :int]
:retry {:count [5 :int]
:enabled [true :bool]}}}}}
:tracer {:jaeger_service_name "test_service"
:tracer {:enabled [true :bool]
:jaeger_service_name "test_service"
:jaeger_endpoint "test_endpoint"
:jaeger_reporter_log_spans [true :bool]}}}
6 changes: 3 additions & 3 deletions src/ziggurat/tracer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
(io.opentracing.noop NoopTracerFactory)))

(defn- create-tracer []
(let [jaeger-service-name (-> (ziggurat-config) :tracer :jaeger_service_name)]
(if (nil? jaeger-service-name)
(let [tracer-config (:tracer (ziggurat-config))]
(if (or (nil? tracer-config) (false? (:enabled tracer-config)))
(NoopTracerFactory/create)
(.getTracer (Configuration/fromEnv jaeger-service-name)))))
(.getTracer (Configuration/fromEnv (:jaeger_service_name tracer-config))))))

(defstate tracer
:start (create-tracer)
Expand Down
7 changes: 7 additions & 0 deletions test/ziggurat/tracer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
(mount/stop))

(testing "should start NoopTracer when tracer is not enabled"
(fix/mount-config)
(with-redefs [ziggurat-config (fn [] {:tracer {:enabled false}})]
(mount/start (mount/only [#'tracer/tracer]))
(is (= "NoopTracerImpl" (.getSimpleName (.getClass tracer/tracer)))))
(mount/stop))

(testing "should start NoopTracer when tracer is not configured"
(fix/mount-config)
(with-redefs [ziggurat-config (fn [] {})]
(mount/start (mount/only [#'tracer/tracer]))
Expand Down

0 comments on commit a0f425f

Please sign in to comment.