-
Notifications
You must be signed in to change notification settings - Fork 157
Add messaging wrappers to support lightweight manual instrumentation #1855
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
base: main
Are you sure you want to change the base?
Conversation
* <p>Inspired from <a | ||
* href=https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/messaging/MessagingAttributesGetter.java>MessagingAttributesGetter</a>. | ||
*/ | ||
public interface MessagingProcessRequest { |
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.
Can define separate extractors for each implementation instead of implementing this interface for each implementation? that would seem more similar to the existing instrumentation extractor design
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.
separate extractors for each implementation instead of implementing this interface for each implementation
Sorry, I don't think so.
If we do that, users have got to create an AttributesExtractor
for each manual implementation, rather than reuse the DefaultMessagingAttributesGetter
. Therefore, users should associate the attributes keys defined in semconv with the fields of messages - it's normally hard (semconv attributes are not such stable, and users may always ignore documents...), and that's one of reasons why we give the process wrapper today.
Conversely, if we give this interface. We can take advantage of the self-explanatory nature of the method names and add java comments to tell users what this value should point to. This process seems more natural, especially for those users who are not such familiar to OTel.
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.
I don't disagree with your reasoning, but doesn't that same reasoning apply to all of the existing instrumentation api semconv attribute extractor design?
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.
Maybe I didn't get your point. Are you suggesting a design like this:
Drop the interface of MessagingProcessRequest
and create a interface of MessagingAttribute
(or reuse that in instrumentations)
If we do so, the complexity for manual users may increase slightly—they will need to implement the MyMessagingGetter
and define a request in cases where the framework's provided message structure is insufficient to retrieve all attributes (similar to KafkaProcessRequest). This is also why I didn't reuse the design of MessagingAttributesGetter
—I believe it might introduce additional cognitive overhead.
However, if you prefer to maintain consistency in the design to make it easier for developers to manage, that makes sense as well. I can adjust my implementation to align with the instrumentation as much as possible.
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.
If we do so, the complexity for manual users may increase slightly—they will need to implement the
MyMessagingGetter
and define a request in cases where the framework's provided message structure is insufficient to retrieve all attributes (similar to KafkaProcessRequest). This is also why I didn't reuse the design ofMessagingAttributesGetter
—I believe it might introduce additional cognitive overhead.
yeah, it's a good point, but I'd prefer to stay consistent with existing instrumentation.
ideally most users of this will be using our pre-built implementations (e.g. for kafka and mns) and so hopefully won't even be aware of which design we use
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.
It makes sense to me. I'll adjust this implementation.
❌ The result from spotlessApply could not be committed to the PR branch, see logs: https://github.com/open-telemetry/opentelemetry-java-contrib/actions/runs/15303539997. |
Update:
|
Some feedback: reducing the complexity of AttributesGetter |
2dd0c16
to
933ad88
Compare
🔧 The result from spotlessApply was committed to the PR branch. |
1 similar comment
🔧 The result from spotlessApply was committed to the PR branch. |
🔧 The result from spotlessApply was committed to the PR branch. |
@trask Hey Trask, I've refactored the design, and we now have an implementation that's very similar to the one in |
Description:
This PR introduces a complete implementation of a generic messaging process wrapper API, designed to facilitate the creation of process spans and the propagation of trace context in a standardized and lightweight manner. It builds upon the initial draft presented in PR #1803, which provides additional context for this work.
Key features and contributions include:
kafka-clients
.aliyun-mns-sdk
(Alibaba Cloud Simple Message Queue).Existing Issue(s):
Testing:
Documentation:
For detailed usage instructions and API documentation, please refer to the updated README.md