-
Notifications
You must be signed in to change notification settings - Fork 228
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
GH-321: Add Observation propagation #325
Conversation
/CC @marcingrzejszczak , @chemicL . I believe it might not be possible to stick with an old Reactor version to preserve the current version. I converted this to Thanks |
Cheering for this PR |
Hi, I think that tracing is still missing in 1.3.17-SNAPSHOT. I managed to turn on traces in 1.3.16 by extending ReactiveKafkaProducerTemplate:
And ReactiveKafkaConsumerTemplate:
I know this solution is far from perfect one but maybe you could move some parts of this code to reactor kafka project. I think it should be located somewhere in DefaultKafkaSender and DefaultKafkaReceiver or there should be some option to register proper listeners. @artembilan - Could you please comment on this? |
Thank you for sharing the code, but what you show so far has nothing to do with Reactor Kafka. Your producer side is similar to what I did in the I'm not sure in your It is also not fair to say |
Thank you for your comment. Much appreciated. I understand this is related to Spring for Apache Kafka but under the hood spring-kafka uses DefaultKafkaSender. Since I have no opportunity to adjust this code I had to make a workaround and I wrapped usage of DefaultKafkaSender:
I just wanted to share that in case of sender it may work like this:
I'm aware that 1.3.17-SNAPSHOT is not finished, I just did not know if you were planning to add the support for tracing in this release and I wanted to tell that in current library I could not find it. Regarding .contextWrite(Function.identity()), I was just playing with that function, the traces for receiving message are visible in Tempo but the trace id are not visible in logs so I tried everything. It helped me in case of Mongo reactive repos. To be honest I do not know how to wrap around the whole Flux/Mono on the consumer side to track receiving the message. |
I have went through PRs and seems I get your point related to callback. I managed to do something like this and it works:
To invoke it I simply use this:
I'm not sure the Function is the best approach here but for now, I'm ok with that and in the future, I'm sure I will have no such challenges with 1.3.17 :) |
Sure! That's also possible. We can consider it as an API evolution: I believe my current low-level approach still can be used for regular The discussion is not over yet: your feedback is really valuable. Thank you! |
Thank you Artem, Yes with transformDeffered all further actions were gone in trace graphs, like saving in mongo for instance. I ended up with:
This produce nice trace graph: |
src/main/java/reactor/kafka/receiver/observation/KafkaRecordReceiverContext.java
Outdated
Show resolved
Hide resolved
src/main/java/reactor/kafka/receiver/observation/KafkaRecordReceiverContext.java
Outdated
Show resolved
Hide resolved
src/main/java/reactor/kafka/receiver/observation/ReceiverObservations.java
Outdated
Show resolved
Hide resolved
src/main/java/reactor/kafka/receiver/observation/KafkaReceiverObservation.java
Outdated
Show resolved
Hide resolved
Just checking on this PR, it is a great initiative, hope there is nothing blocking it! |
Hello team, the latest v1.3.18 only had one change. It seems the repo is quite stable lately. Would it be possible to merge this? |
I didn't come up with clean end-user API for Consumer observation. |
Was about to start a feature request for the same. Found this (long opened) thread. Big +1 for this! What is blocking the merge please? |
Any update on this MR ? |
Hi @artembilan, any chance to merge this in near future? Thanks |
OK. I'm not sure who to ask for review on this, so I went ahead with closest contacts who are aware of this project and the stuff I do in the change. Thank you every one for feedback and sorry for delay! |
This is great! Thanks @artembilan ! Hope this can be merged! |
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 - any thoughts about adding documentation?
We can merge this for next week's release, if you prefer, and add docs later?
I had a look. It looks like this is an important improvement for the lives of developers :) I have a few questions/suggestions to understand the implementation and the intentions:
|
* Revert new version `1.4` * Don't use `contextCapture()` in the `DefaultKafkaSender`: better to ask end-users to use a `contextWrite()` for the parent observation to propagate * `ReceiverObservations` factories to observe `ConsumerRecord` on the end-user side via `transformDeferred()` on each record
* Fix deprecation in the `ConsumerHandler` for `eventScheduler.start()` * Use generated `producerId` and `receiverId` if `CLIENT_ID_CONFIG` is not provided * Use an `Observation` in the `DefaultKafkaReceiver` to add a `CONSUMER` span to the trace provided by the `PRODUCER` in the record. * Recommend to use a `KafkaReceiverObservation.RECEIVER_OBSERVATION` API directly in the target end-user code when need to have an observation context around record handling
* Exclude `org.mockito` from Micrometer deps since we cannot use a newer version of Mockito yet
* Add docs about observation support
Co-authored-by: Gary Russell <[email protected]>
This is great! Thanks! I would like to help test this. Just to be sure I am testing the "right thing" Should I pull the latest available snapshot from https://repo.spring.io/snapshot ? |
Hello @garyrussell, @artembilan, |
November 7: https://calendar.spring.io/ |
yes, the latest SNAPSHOT is available in that repo. |
Hi @artembilan , @garyrussell |
@garyrussell 7 November or 14? |
@michalwilk96 Adding the milestone to the issue and to the PR as well would show up as a duplicate so usually the milestone is added to the issue: #321 |
Just added that issue to the respective milestone. |
Hello team, Just verified 1.3.22 was not part of SpringBoot 3.2.0-RC2 Would it be possible to have this PR as part of the official 3.2.0 release due one week after 1.3.22 of reactor kafka? Thank you |
This is release is going to be a part of upcoming Reactor release trains tomorrow. |
@jonatan-ivanov That's not how we do this in Project Reactor. It is important that PRs has the milestone and the type, because we need to generate the release notes based on this information. |
Hi @marcingrzejszczak , Here in this change, type casting(String) is used for bootstrap.severs value and when I am passing my server values(e.g listOf(val1,val2) as mentioned here in springframework, then it is giving type cast exception as below
|
this has nothing to do with observation support. we cannot change that to realign with Spring Boot option in the current patch version. here is how you have to configure for now on:
Feel free to raise a new GH issue, so we will review this when we start a new version. and stop, please, comment on old closed issues/PRs: the comment might not be related to the subject or easily lost. Because , you know , it is closed already . |
Fixes #321
KafkaReceiverObservation
&KafkaSenderObservation
infrastructure from Spring for Apache KafkaObservation
handling into aKafkaSender
withcontextCapture()
andKafkaSenderObservation
aroundproducer.send()
Observation
handling on the consumer side is only around a consumer record to start and stop immediately to fill a gap forCOSNUMER
kind span in the propagated trace from producer.If there is need to propagate an observation to downstream flow, then
KafkaReceiverObservation
API has to be used in theflatMap()
around theMono
for record processing.ReactorKafkaObservationTests
demonstrates a single trace propagation from a sender via parentObservation
and its restoration on a consumer side viaKafkaReceiverObservation
in the end-user code