Skip to content

Commit 900d010

Browse files
authored
[Feature/EV-38] Remove opentracing code (#275)
* [EV-38][Indra] Remove modules tracer and tracer-test * [EV-38][Indra] Remove opentracing tests from consumer-connection test * [EV-38][Indra] Remove opentracing from connection_helper * [EV-38][Indra] Remove opentracing from ziggurat.producer * [EV-38][Indra] Remove opentracing tests from ziggurat.messaging.producer-test * [EV-38][Indra] Remove opentracing init-test * [EV-38][Indra] Remove tracer-enabled arg to connection helper from producer connection helper test * [EV-38][Indra] Remove tracer related test from consumer_test * [EV-38][Indra] Remove opentracing related dependencies from project.clj and fixtures * [EV-38][Indra] Remove opentracing content from Readme * [EV-38][Indra] Remove opentracing from streams * [EV-38][Indra] Fix linting * [EV-38][Indra] Remove ziggurat.tracer references * [EV-38][Indra] Bump the version to v4.9.4
1 parent a10c481 commit 900d010

18 files changed

+46
-496
lines changed

README.md

-32
Original file line numberDiff line numberDiff line change
@@ -425,38 +425,6 @@ and different timeout values.
425425
:enable [true :bool]}}}}}
426426
```
427427

428-
## Tracing
429-
430-
[Open Tracing](https://opentracing.io/docs/overview/) enables to identify the amount of time spent in various stages of the work flow.
431-
432-
Currently, the execution of the handler function is traced. If the message consumed has the corresponding tracing headers, then the E2E life time of the message from the time of production till the time of consumption can be traced.
433-
434-
Tracing has been added to the following flows:
435-
436-
1. Normal basic consume
437-
2. Retry via rabbitmq
438-
3. Produce to rabbitmq channel
439-
4. Produce to another kafka topic
440-
441-
By default, tracing is done via [Jaeger](https://www.jaegertracing.io/) based on the env configs. Please refer [Jaeger Configuration](https://github.com/jaegertracing/jaeger-client-java/tree/master/jaeger-core#configuration-via-environment)
442-
and [Jaeger Architecture](https://www.jaegertracing.io/docs/1.13/architecture/) to set the respective env variables.
443-
To enable custom tracer, a custom tracer provider function name can be set in `:custom-provider`. The corresponding function will be executed in runtime to create a tracer. In the event of any errors while executing the custom tracer provider, a Noop tracer will be created.
444-
445-
To enable tracing, the following config needs to be added to the `config.edn` under `:ziggurat` key.
446-
447-
```clojure
448-
:tracer {:enabled [true :bool]
449-
:custom-provider ""}
450-
```
451-
452-
Example Jaeger Env Config:
453-
454-
```
455-
JAEGER_SERVICE_NAME: "service-name"
456-
JAEGER_AGENT_HOST: "localhost"
457-
JAEGER_AGENT_PORT: 6831
458-
```
459-
460428
## Deprecation Notice
461429
* Sentry has been deprecated.
462430

project.clj

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(cemerick.pomegranate.aether/register-wagon-factory!
33
"http" #(org.apache.maven.wagon.providers.http.HttpWagon.))
44

5-
(defproject tech.gojek/ziggurat "4.9.3"
5+
(defproject tech.gojek/ziggurat "4.9.4"
66
:description "A stream processing framework to build stateless applications on kafka"
77
:url "https://github.com/gojektech/ziggurat"
88
:license {:name "Apache License, Version 2.0"
@@ -22,12 +22,6 @@
2222
[mount "0.1.16"]
2323
[io.jaegertracing/jaeger-core "1.6.0"]
2424
[io.jaegertracing/jaeger-client "1.6.0"]
25-
[io.opentracing/opentracing-api "0.33.0"]
26-
[io.opentracing/opentracing-mock "0.33.0"]
27-
[io.opentracing/opentracing-noop "0.33.0"]
28-
[io.opentracing.contrib/opentracing-kafka-streams "0.1.15" :exclusions [org.lz4/lz4-java com.github.luben/zstd-jni org.apache.kafka/kafka-streams org.slf4j/slf4j-api org.xerial.snappy/snappy-java]]
29-
[io.opentracing.contrib/opentracing-kafka-client "0.1.15" :exclusions [org.lz4/lz4-java com.github.luben/zstd-jni org.slf4j/slf4j-api org.xerial.snappy/snappy-java]]
30-
[io.opentracing.contrib/opentracing-rabbitmq-client "0.1.11" :exclusions [com.rabbitmq/amqp-client]]
3125
[org.apache.httpcomponents/fluent-hc "4.5.13"]
3226
[org.apache.kafka/kafka-clients "2.8.2" :exclusions [org.slf4j/slf4j-log4j12 log4j]]
3327
[org.apache.kafka/kafka-streams "2.8.2" :exclusions [org.slf4j/slf4j-log4j12 log4j]]

resources/config.test.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
:default-api-timeout-ms-config [60000 :int]
9292
:key-deserializer-class-config "org.apache.kafka.common.serialization.ByteArrayDeserializer"
9393
:value-deserializer-class-config "org.apache.kafka.common.serialization.ByteArrayDeserializer"}}
94-
:tracer {:enabled [true :bool]
94+
:tracer {:enabled [false :bool]
9595
:custom-provider ""}
9696
:new-relic {:report-errors false}
9797
:log-format "text"}}

src/ziggurat/init.clj

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
[ziggurat.sentry :refer [sentry-reporter]]
2222
[ziggurat.server :as server]
2323
[ziggurat.streams :as streams]
24-
[ziggurat.tracer :as tracer]
2524
[ziggurat.util.java-util :as util])
2625
(:gen-class
2726
:methods [^{:static true} [init [java.util.Map] void]]
@@ -150,15 +149,13 @@
150149
(defn start-common-states []
151150
(start* #{#'metrics/statsd-reporter
152151
#'sentry-reporter
153-
#'nrepl-server/server
154-
#'tracer/tracer}))
152+
#'nrepl-server/server}))
155153

156154
(defn stop-common-states []
157155
(mount/stop #'config/config
158156
#'sentry-reporter
159157
#'metrics/statsd-reporter
160-
#'nrepl-server/server
161-
#'tracer/tracer))
158+
#'nrepl-server/server))
162159

163160
(defn start
164161
"Starts up Ziggurat's config, reporters, actor fn, rabbitmq connection and then streams, server etc"

src/ziggurat/messaging/connection_helper.clj

+3-8
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
[ziggurat.config :refer [ziggurat-config]]
66
[ziggurat.sentry :refer [sentry-reporter]]
77
[ziggurat.channel :refer [get-keys-for-topic]]
8-
[ziggurat.tracer :refer [tracer]]
98
[ziggurat.messaging.util :as util]
109
[ziggurat.util.error :refer [report-error]])
1110
(:import [com.rabbitmq.client ShutdownListener ConnectionFactory AddressResolver]
1211
[java.util.concurrent Executors ExecutorService]
13-
[io.opentracing.contrib.rabbitmq TracingConnectionFactory]
1412
[com.rabbitmq.client.impl DefaultCredentialsProvider]))
1513

1614
(defn is-connection-required? []
@@ -48,10 +46,8 @@
4846
(util/create-address-resolver rabbitmq-config)
4947
(:connection-name rabbitmq-config))))
5048

51-
(defn create-connection [config tracer-enabled]
52-
(if tracer-enabled
53-
(create-rmq-connection (TracingConnectionFactory. tracer) config)
54-
(create-rmq-connection (ConnectionFactory.) config)))
49+
(defn create-connection [config]
50+
(create-rmq-connection (ConnectionFactory.) config))
5551

5652
(defn- get-connection-config
5753
[is-producer?]
@@ -70,8 +66,7 @@
7066
(when (is-connection-required?)
7167
(try
7268
(let
73-
[is-tracer-enabled? (get-in (ziggurat-config) [:tracer :enabled])
74-
connection (create-connection (get-connection-config is-producer?) is-tracer-enabled?)]
69+
[connection (create-connection (get-connection-config is-producer?))]
7570
(log/info "Connection created " connection)
7671
(doto connection
7772
(.addShutdownListener

src/ziggurat/producer.clj

+4-7
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@
4545
(:require [clojure.tools.logging :as log]
4646
[mount.core :refer [defstate]]
4747
[ziggurat.config :refer [build-producer-config-properties ziggurat-config]]
48-
[ziggurat.tracer :refer [tracer]]
4948
[ziggurat.util.java-util :refer [get-key]])
50-
(:import (io.opentracing.contrib.kafka TracingKafkaProducer)
51-
(org.apache.kafka.clients.producer KafkaProducer ProducerRecord))
49+
(:import (org.apache.kafka.clients.producer KafkaProducer ProducerRecord))
5250
(:gen-class
5351
:methods [^{:static true} [send [String String Object Object] java.util.concurrent.Future]
5452
^{:static true} [send [String String int Object Object] java.util.concurrent.Future]]
@@ -70,9 +68,8 @@
7068
(do (log/info "Starting Kafka producers ...")
7169
(reduce (fn [producers [stream-config-key properties]]
7270
(log/debug "Constructing Kafka producer associated with [" stream-config-key "] ")
73-
(let [kp (KafkaProducer. properties)
74-
tkp (TracingKafkaProducer. kp tracer)]
75-
(assoc producers stream-config-key tkp)))
71+
(let [kp (KafkaProducer. properties)]
72+
(assoc producers stream-config-key kp)))
7673
{}
7774
(seq (producer-properties-map))))
7875
(log/info "No producers found. Can not initiate start."))
@@ -85,7 +82,7 @@
8582
(.flush)
8683
(.close)))
8784
(seq kafka-producers))))
88-
(log/info "No producers found.n Can not initiate stop.")))
85+
(log/info "No producers found. Can not initiate stop.")))
8986

9087
(defn send
9188
"A wrapper around `org.apache.kafka.clients.producer.KafkaProducer#send` which enables

src/ziggurat/streams.clj

+11-25
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@
88
[ziggurat.message-payload :refer [->MessagePayload]]
99
[ziggurat.metrics :as metrics]
1010
[ziggurat.timestamp-transformer :as timestamp-transformer]
11-
[ziggurat.tracer :refer [tracer]]
1211
[ziggurat.util.map :as umap]
1312
[cambium.core :as clog])
14-
(:import [io.opentracing.contrib.kafka TracingKafkaUtils]
15-
[io.opentracing.contrib.kafka.streams TracingKafkaClientSupplier]
16-
[io.opentracing.tag Tags]
17-
[java.time Duration]
13+
(:import [java.time Duration]
1814
[java.util Properties]
1915
[java.util.regex Pattern]
2016
[org.apache.kafka.common.errors TimeoutException]
@@ -126,22 +122,13 @@
126122
(doseq [[topic-entity stream] streams]
127123
(close-stream topic-entity stream)))
128124

129-
(defn- traced-handler-fn [handler-fn channels message topic-entity]
130-
(let [parent-ctx (TracingKafkaUtils/extractSpanContext (:headers message) tracer)
131-
span (as-> tracer t
132-
(.buildSpan t "Message-Handler")
133-
(.withTag t (.getKey Tags/SPAN_KIND) Tags/SPAN_KIND_CONSUMER)
134-
(.withTag t (.getKey Tags/COMPONENT) "ziggurat")
135-
(if (nil? parent-ctx)
136-
t
137-
(.asChildOf t parent-ctx))
138-
(.start t))]
139-
(try
140-
((mapper-func handler-fn channels) (-> (->MessagePayload (:value message) topic-entity)
141-
(assoc :headers (:headers message))
142-
(assoc :metadata (:metadata message))))
143-
(finally
144-
(.finish span)))))
125+
(defn- mapped-handler-fn [handler-fn channels message topic-entity]
126+
(try
127+
((mapper-func handler-fn channels)
128+
(-> (->MessagePayload (:value message) topic-entity)
129+
(assoc :headers (:headers message))
130+
(assoc :metadata (:metadata message))))
131+
(finally)))
145132

146133
(defn- join-streams
147134
[oldest-processed-message-in-s topic-entity stream-1 stream-2]
@@ -187,7 +174,7 @@
187174
{stream :stream} (reduce (partial join-streams oldest-processed-message-in-s topic-entity) stream-map)]
188175
(->> stream
189176
(header-transform-values)
190-
(map-values #(traced-handler-fn handler-fn channels % topic-entity)))
177+
(map-values #(mapped-handler-fn handler-fn channels % topic-entity)))
191178
(.build builder))))
192179

193180
(defn- topology [handler-fn {:keys [origin-topic oldest-processed-message-in-s]} topic-entity channels]
@@ -198,7 +185,7 @@
198185
(timestamp-transform-values topic-entity-name oldest-processed-message-in-s)
199186
(header-transform-values)
200187
(map-values #(log-and-report-metrics topic-entity-name %))
201-
(map-values #(traced-handler-fn handler-fn channels % topic-entity)))
188+
(map-values #(mapped-handler-fn handler-fn channels % topic-entity)))
202189
(.build builder)))
203190

204191
(defn- start-stream* [handler-fn stream-config topic-entity channels]
@@ -209,8 +196,7 @@
209196

210197
(when-not (nil? top)
211198
(KafkaStreams. ^Topology top
212-
^Properties (properties stream-config)
213-
(new TracingKafkaClientSupplier tracer)))))
199+
^Properties (properties stream-config)))))
214200

215201
(defn- merge-consumer-type-config
216202
[config]

src/ziggurat/tracer.clj

-92
This file was deleted.

test/ziggurat/fixtures.clj

+2-13
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
[ziggurat.messaging.util :as util]
1515
[ziggurat.metrics :as metrics]
1616
[ziggurat.producer :as producer]
17-
[ziggurat.server :refer [server]]
18-
[ziggurat.tracer :as tracer])
19-
(:import (io.opentracing.mock MockTracer)
20-
(java.util Properties)
17+
[ziggurat.server :refer [server]])
18+
(:import (java.util Properties)
2119
(org.apache.kafka.clients.consumer ConsumerConfig)
2220
(org.apache.kafka.clients.producer ProducerConfig))
2321
(:gen-class
@@ -67,14 +65,8 @@
6765
(f)
6866
(mount/stop #'metrics/statsd-reporter))
6967

70-
(defn mount-tracer []
71-
(with-redefs [tracer/create-tracer (fn [] (MockTracer.))]
72-
(-> (mount/only [#'tracer/tracer])
73-
(mount/start))))
74-
7568
(defn mount-config-with-tracer [f]
7669
(mount-config)
77-
(mount-tracer)
7870
(f)
7971
(mount/stop))
8072

@@ -119,8 +111,6 @@
119111
(let [stream-routes {:default {:handler-fn #(constantly nil)
120112
:channel-1 #(constantly nil)}}]
121113
(mount-config)
122-
(mount-tracer)
123-
124114
(->
125115
(mount/only [#'producer-connection #'consumer-connection #'channel-pool])
126116
(mount/with-args {:stream-routes stream-routes})
@@ -163,7 +153,6 @@
163153

164154
(defn mount-producer-with-config-and-tracer [f]
165155
(mount-config)
166-
(mount-tracer)
167156
(mount-producer)
168157
(binding [*bootstrap-servers* (get-in (config/ziggurat-config) [:stream-router :default :bootstrap-servers])]
169158
(binding [*consumer-properties* (doto (Properties.)

0 commit comments

Comments
 (0)