-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add observation for message channels #3944
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 observation for message channels #3944
Conversation
46daad1
to
37d3e96
Compare
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.
Commit comment would have been helpful.
|
||
private boolean sendWithObservation(Message<?> message, long timeout) { | ||
MutableMessage<?> messageToSend = MutableMessage.of(message); | ||
MessageSenderContext context = new MessageSenderContext(messageToSend, getComponentName()); |
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.
Unnecessary local variable.
} | ||
|
||
private boolean sendWithObservation(Message<?> message, long timeout) { | ||
MutableMessage<?> messageToSend = MutableMessage.of(message); |
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.
Why?
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.
See the MessageSenderContext
implementation.
The MessageChannel.send()
is really a point in Spring Integration where we produce messages.
According to PRODUCER
entity of the observation, we have to expose some Setter
which would carry on values from the current context to downstream consumers - propagation, essentially.
Therefore a MutableMessage
to be able to modify headers in the trace Propagator
.
See ObservationPropagationChannelInterceptorTests
.
Or is your "Why?" about this new of()
factory method? 😄
Sure! I can add more info into commit message if we are really on the same page about the solution after this review and discussion.
Thank you for understanding!
P.S. Perhaps I deliberately have left so little info in the PR, therefore you would pay attention for what is going on and we would have a healthy discussion like 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.
Yes, I missed the getHeaders().put(...)
; now I see it.
I will be honest in that I still don't see why we need to observe channel sends, it seems much too fine-grained to me.
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.
Well, if channel is distributed, then we just lose the producer point of the trace.
It is really up to end-user now what to chose for instrumentation.
Perhaps they indeed would apply only inbound and outbound channel adapters.
However the current solution with Sleuth is only channel instrumentation 🤷
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.
Ok; just address my other comment and will merge.
The `MessageChannel.send()` is, essentially, only the point in Spring Integration where we produce a message and can emit a `PRODUCER` kind span. * Implement `IntegrationObservation.PRODUCER` infrastructure based on the `MessageSenderContext` * Implement an observation emission in the `AbstractMessageChannel` based on the mentioned `IntegrationObservation.PRODUCER` * Build a `MutableMessage.of(message)` to be able to modify message header in the `MessageSenderContext` via tracer `Propagator` or other tracing injection instrument * Document which components are instrumented with an `ObservationRegistry`
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.
Doc polishing.
Co-authored-by: Gary Russell <[email protected]>
No description provided.