-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenTelemetry support #633
Conversation
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTracingHandle.java
Outdated
Show resolved
Hide resolved
@alesj please could you provide a description for this PR, and an issue reference if there is one? Thanks. |
Short description provided. |
I created a corresponding issue for tracking #636 |
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
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.
Thanks @alesj! I left a few comments and questions.
src/main/java/io/strimzi/kafka/bridge/tracing/TracingHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/TracingHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/http/HttpSourceBridgeEndpoint.java
Show resolved
Hide resolved
@BeforeEach | ||
public void setUp() { | ||
assumeServer(String.format("http://%s:%s", Urls.BRIDGE_HOST, Urls.BRIDGE_PORT)); // bridge | ||
assumeServer("http://localhost:16686"); // 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.
I think it would be better if we could use testcontainers to spin up a server. I admit I've no idea how much work that would really, but maybe it's not so much?
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.
With testcontainers it's chicken-n-egg problem ... you would first need to build latest Bridge image, only to be used in tests then.
Perhaps I can easily make it work with running Application::main with the right args ...
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.
Ah, now I know why I added that service.name property to Bridge config ... otherwise you can only enable OpenTracing via env vars ... which makes it hard (if not impossible) to test.
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.
Something like this is then required - custom generic containers:
I can give it a shot if it's really needed ...
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.
Looking at Ales's branch I'm inclined to thiat bridge support for the test-clients would be a great addition. @ppatierno @scholzj wdyt?
7eee00a
to
36240b5
Compare
src/main/java/io/strimzi/kafka/bridge/tracing/TracingHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
9bd61e1
to
65d6e10
Compare
src/main/java/io/strimzi/kafka/bridge/tracing/TracingHandle.java
Outdated
Show resolved
Hide resolved
protected abstract TracingOptions tracingOptions(); | ||
|
||
@Test | ||
public void testSmoke(VertxTestContext context) throws Exception { |
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 am not sure what we are testing here. Actually we are using the vertx-tracing support just for enabling tracing on the client side (because the Vertx
instance we are creating is used for the web client part) but then we are sending/receiving messages but when actually the tracing part is tested? Tbh I don't think we had anything before as well, but this test is not adding much more.
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.
Yeah, atm the 'test' only adds simple automation of send+receive -- so you don't have to do it completely manually (via curl, postman, etc).
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.
@tombentley do you think we should keep it anyway or just remove? Maybe opening an issue about adding proper tracing tests later?
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.
Maybe opening an issue about adding proper tracing tests later?
+1
With the current status of the PR we are avoiding the hack we had before about tracking spans with a UUID for using the right tracing context in the Kafka producer interceptor due to the async nature of Vert.x and different threads usage. Unluckily the current solution has a problem when an HTTP client uses the "keep-alive" connection enabled. Of course with no "keep-alive" everything works fine each time, because a new Kafka client is created for every HTTP request and the context is always the "right" one. Meanwhile we already have the "workaround" which is actually a middle solution (pushed by Ales during these days to avoid the above mentioned hack) about using an executor service which is wrapped through the Context (in OpenTelemetry) in order to use the right context in Vert.x. This is more or less the status of the art. If there is no trick for the Vert.x Kafka client or we would need a change on the client so waiting for a new release, I would move forward with this PR by using the last "workaround" and then tracking an issue to come back using the storage later. Last consideration is that Vert.x seems to have an official support for tracing now, both for OpenTelemetry and OpenTracing but seems to be still in TP and anyway using it would need a more bigger refactoring on the bridge because such support handle the HTTP part of the tracing for us our of box, so we should remove our code. I am against this solution in the near future. I would like to know what the other maintainers think about the overall picture of this. @tombentley @scholzj ? |
Thanks to Julien from the Vert.x team, we have got a fix in the Vert.x Kafka client (vert-x3/vertx-kafka-client#226) which I tested and seems to work. Of course, this will be available in the next Vert.x 4.3.3 release. An ETA seems to be August for having this release. @tombentley @scholzj what's your feeling on this? |
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Remove OTel span propagation hack. Simplify executor service adapt. Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Finally Vert.x 4.3.3 is out! @alesj could you update the PR by using this release and test again that everything works fine please? |
Signed-off-by: Ales Justin <ales.justin@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.
@alesj I left some comments mostly around dependencies that can be safely removed
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
src/main/java/io/strimzi/kafka/bridge/http/HttpSinkBridgeEndpoint.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/http/HttpSinkBridgeEndpoint.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/http/HttpSourceBridgeEndpoint.java
Show resolved
Hide resolved
@@ -96,70 +85,45 @@ public void handle(Endpoint<?> endpoint) { | |||
|
|||
boolean isAsync = Boolean.parseBoolean(routingContext.queryParams().get("async")); | |||
|
|||
Tracer tracer = GlobalTracer.get(); |
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.
Not for this PR I guess, but this handle()
method is pretty complex. We should try to refactor it into smaller methods.
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTelemetryHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/TracingHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTracingHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/OpenTracingHandle.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/tracing/TracingHandle.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Ales Justin <ales.justin@gmail.com>
Signed-off-by: Ales Justin <ales.justin@gmail.com>
src/main/java/io/strimzi/kafka/bridge/http/HttpSourceBridgeEndpoint.java
Outdated
Show resolved
Hide resolved
src/main/java/io/strimzi/kafka/bridge/http/HttpSourceBridgeEndpoint.java
Show resolved
Hide resolved
Signed-off-by: Ales Justin <ales.justin@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! @alesj thanks for the effort!
src/main/java/io/strimzi/kafka/bridge/http/HttpSourceBridgeEndpoint.java
Show resolved
Hide resolved
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.
Thanks Ales!
This PR adds OpenTelemetry support.
It abstract previous OpenTracing / Jaeger usage -- adding thin abstraction layer to hide actual implementation usage.
Most of the old code was used as it is, only
poll
orconsume
was changed away from interceptor usage - as we couldn't model trace/spans as expected.Async send needed some extra work for OTel, due to its ThreadLocal current span propagation.
Current
bridge.tracing
property must be set toopentelemetry
to use OTel tracing.