Skip to content

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

Merged
merged 3 commits into from
Nov 15, 2022

Conversation

artembilan
Copy link
Member

No description provided.

Copy link
Contributor

@garyrussell garyrussell left a 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());
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

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 😉

Copy link
Contributor

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.

Copy link
Member Author

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 🤷

Copy link
Contributor

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`
Copy link
Contributor

@garyrussell garyrussell left a 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]>
@garyrussell garyrussell merged commit 88e259c into spring-projects:main Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants