-
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
Merged
garyrussell
merged 3 commits into
spring-projects:main
from
artembilan:channel_observation
Nov 15, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...integration/support/management/observation/DefaultMessageSenderObservationConvention.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.integration.support.management.observation; | ||
|
||
import io.micrometer.common.KeyValues; | ||
|
||
/** | ||
* A default {@link MessageSenderObservationConvention} implementation. | ||
* Provides low cardinalities as a {@link IntegrationObservation.ProducerTags} values. | ||
* | ||
* @author Artem Bilan | ||
* | ||
* @since 6.0 | ||
*/ | ||
public class DefaultMessageSenderObservationConvention implements MessageSenderObservationConvention { | ||
|
||
/** | ||
* A shared singleton instance for {@link DefaultMessageSenderObservationConvention}. | ||
*/ | ||
public static final DefaultMessageSenderObservationConvention INSTANCE = | ||
new DefaultMessageSenderObservationConvention(); | ||
|
||
|
||
@Override | ||
public KeyValues getLowCardinalityKeyValues(MessageSenderContext context) { | ||
return KeyValues | ||
// See IntegrationObservation.ProducerTags.COMPONENT_NAME - to avoid class tangle | ||
.of("spring.integration.name", context.getProducerName()) | ||
// See IntegrationObservation.ProducerTags.COMPONENT_TYPE - to avoid class tangle | ||
.and("spring.integration.type", "producer"); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
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 someSetter
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 tracePropagator
.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.