-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Added support for opentelemetry #83
Added support for opentelemetry #83
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just one nit!
@@ -34,12 +34,14 @@ public class KafkaConsumerConfig { | |||
private final String oauthTokenEndpointUri; | |||
private final String additionalConfig; | |||
private final String saslLoginCallbackClass = "io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler"; | |||
private final String tracingSystem; | |||
private static final String DEFAULT_TRACING_SYSTEM = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strings are null by default so you can remove = null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without initialising to null, I'm getting the following error - Variable 'DEFAULT_TRACING_SYSTEM' might not have been initialized
@@ -89,14 +93,14 @@ public static Properties createProperties(KafkaConsumerConfig config) { | |||
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); | |||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer"); | |||
|
|||
if (config.getSslTruststoreCertificates() != null) { | |||
if (config.getSslTruststoreCertificates() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: If we're removing extra spaces, let's remove them all! Otherwise undo this change.
Same below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undone
Tracer tracer = Configuration.fromEnv().getTracer(); | ||
GlobalTracer.registerIfAbsent(tracer); | ||
TracingSystem tracingSystem; | ||
tracingSystem = TracingSystem.forValue(config.getTracingSystem()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we merge these 2 lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merged
|
||
props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingConsumerInterceptor.class.getName()); | ||
props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, io.opentracing.contrib.kafka.TracingConsumerInterceptor.class.getName()); | ||
} else if (tracingSystem == KafkaConsumerExample.TracingSystem.OPENTELEMETRY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to drop the KafkaConsumerExample.
prefix here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped without any issues.
@@ -62,4 +87,4 @@ public static void main(String[] args) { | |||
} | |||
log.info("Received {} messages", receivedMsgs); | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep the newline. Same in a few other files below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean an extra empty line at the bottom? If so, added.
java/kafka/deployment-tracing.yaml
Outdated
@@ -95,6 +97,8 @@ spec: | |||
value: const | |||
- name: JAEGER_SAMPLER_PARAM | |||
value: "1" | |||
- name: TRACING_SYSTEM | |||
value: "jaeger" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quotes removed
|
||
props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, TracingConsumerInterceptor.class.getName()); | ||
props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG, io.opentracing.contrib.kafka.TracingConsumerInterceptor.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the import and use the short name instead of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason the import prefix is added here instead of keeping the import is: Jaeger (opentracing) and opentelemetry use the same class name and the only way i could differencieate between the two is to add the import in the lines of code. Is there another way to do this? Thanks. See below:
props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG,io.opentracing.contrib.kafka.TracingConsumerInterceptor.class.getName());
props.put(ConsumerConfig.INTERCEPTOR_CLASSES_CONFIG,io.opentelemetry.instrumentation.kafkaclients.TracingConsumerInterceptor.class.getName());
@@ -26,6 +25,21 @@ | |||
public class KafkaProducerExample { | |||
private static final Logger log = LogManager.getLogger(KafkaProducerExample.class); | |||
|
|||
public enum TracingSystem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of duplicating this logic, can we extract it into its own class?
c9adda3
to
f82401c
Compare
Signed-off-by: Owen <owencorrigan76@gmail.com>
f82401c
to
c167192
Compare
Signed-off-by: Owen <owencorrigan76@gmail.com>
Signed-off-by: Owen <owencorrigan76@gmail.com>
Signed-off-by: Owen <owencorrigan76@gmail.com>
Signed-off-by: Owen <owencorrigan76@gmail.com>
Signed-off-by: Owen <owencorrigan76@gmail.com>
Signed-off-by: Owen <owencorrigan76@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for this work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pro-tip: If you resolve the addressed comments, the PR will be much more readable.
Signed-off-by: Owen <owencorrigan76@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the PR.
@ppatierno @mimaison Do you need another pass through it? Or can it be merged?
It's fine with me |
* Add OpenTelemetry support Signed-off-by: Owen <owencorrigan76@gmail.com>
Incorporates Opentelemetry alongside OpenTracing to read traces on Producer, Consumer and Streams.
Added OpenTelemetry dependencies as instructed here: [1]
Required Environmental Variables:
[1] https://github.com/ppatierno/kafka-opentelemetry