-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
KafkaTemplate currentSpan tagging issue #3210
Milestone
Comments
sobychacko
added a commit
to sobychacko/spring-kafka
that referenced
this issue
Apr 22, 2024
Fixes: spring-projects#3210 * When adding a tag to the current span during the sending of a kafka message using KafkaTemplate, the tag gets added to another span because KafkaTemplate doesn't open the scope for the started observation. Fixing this issue by wrapping the doSend method call in a proper observation scope. **Auto-cherry-pick to `3.1.x` & `3.0.x`**
artembilan
added
backport-to-3.0.x (obsolete)
for: backport-to-3.1.x
and removed
status: waiting-for-triage
labels
Apr 23, 2024
artembilan
pushed a commit
that referenced
this issue
Apr 23, 2024
Fixes: #3210 * When adding a tag to the current span during the sending of a kafka message using KafkaTemplate, the tag gets added to another span because KafkaTemplate doesn't open the scope for the started observation. Fixing this issue by wrapping the doSend method call in a proper observation scope. **Auto-cherry-pick to `3.1.x` & `3.0.x`**
artembilan
pushed a commit
that referenced
this issue
Apr 23, 2024
Fixes: #3210 * When adding a tag to the current span during the sending of a kafka message using KafkaTemplate, the tag gets added to another span because KafkaTemplate doesn't open the scope for the started observation. Fixing this issue by wrapping the doSend method call in a proper observation scope. **Auto-cherry-pick to `3.0.x`** # Conflicts: # spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java
spring-builds
pushed a commit
that referenced
this issue
Apr 23, 2024
Fixes: #3210 * When adding a tag to the current span during the sending of a kafka message using KafkaTemplate, the tag gets added to another span because KafkaTemplate doesn't open the scope for the started observation. Fixing this issue by wrapping the doSend method call in a proper observation scope. # Conflicts: # spring-kafka/src/test/java/org/springframework/kafka/support/micrometer/ObservationTests.java (cherry picked from commit 59e5a80)
This was referenced Apr 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Affects version
3.1.4
Description
When adding a tag to the current span during the sending of a kafka message using KafkaTemplate,
the tag gets added to another span because the KafkaTemplate doesn't open the scope for the started observation.
The snippet below is the observeSend method in the KafkaTemplate class. It creates an observation object and calls start() but doesn't call openScope().
The micrometer documentation explains how to migrate from sleuth to micrometer.
The KafkaTemplate.observeSend() method uses the manual approach and according to the explanation, a call to openScope and corresponding close should be added.
See: https://github.com/micrometer-metrics/micrometer/wiki/Migrating-to-new-1.10.0-Observation-API#you-want-to-do-everything-manually-or-you-want-to-signal-events
Reproduction scenario
Given
When
Simplified logical flow
Then
Expected
Workaround
Extend the KafkaTemplate class, override the
doSend(producerRecord, observation)
method andenclose the super method call with opening and closing of the scope.
Normally this fix should be done in the
observeSend(producerRecord)
method but unfortunatelythat method is
private
Sample
Sample including description can be found here:
The code for the workaround can be found in the
workaround
branch.The text was updated successfully, but these errors were encountered: