-
Notifications
You must be signed in to change notification settings - Fork 196
fix: add missing semantic conventions require in AWS resource detectors #1520
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
kaylareopelle
merged 4 commits into
open-telemetry:main
from
yiyuan-he:fix-missing-import
May 7, 2025
+5
−0
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
936bc36
fix: add missing semantic conventions require in AWS resource detectors
yiyuan-he e54f72f
fix: add semantic conventions require to top-level file
yiyuan-he c150b05
Merge branch 'main' into fix-missing-import
yiyuan-he 358fde7
Merge branch 'main' into fix-missing-import
kaylareopelle 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
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.
Is there any disadvantage to requiring this dependency once at the top level?
resources/aws/lib/opentelemetry-resource-detector-aws.rb
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, it should be fine to include in the top level.
I was testing through
require 'opentelemetry/resource/detector/aws/ec2'
, and I got the issue.Actually, if I do
require 'opentelemetry-resource-detector-aws'
, then it doesn't need require semantic_conventions/resource (e.g. no uninitialized constant error).I guess I should require the detector through the gem name, not gem file.
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.
Yeah I think our instructions on
opentelemetry.io
are also a bit misleading.In most cases bundler will require the root of the gem and that should be enough to start the require process of all of the files down the tree so we should encourage requiring top levels files 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.
Thanks Ariel and Xuan for the additional context and feedback. I'll push a commit to require the dependency at
resources/aws/lib/opentelemetry-resource-detector-aws.rb
instead.However, i'm curious if we should move forward with these changes and implicitly support this unrecommended dependency import method.
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.
The top level directory requires the
opentelemetry/sdk
which requires the transitive dependencies:https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/resources/aws/lib/opentelemetry/resource/detector.rb#L7
https://github.com/open-telemetry/opentelemetry-ruby/blob/main/sdk/lib/opentelemetry/sdk.rb#L10
Is your preference that all of these dependencies be explicitly required?
Is that because each sub detector may be used in isolation without loading the other detectors?
If so, then for consistency I think you all should treat each as their own nested library and explicitly require all dependencies.
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.
Thanks Ariel - that's helpful context. Yes, the intention is to allow sub-detectors to be used in isolation. I'll update the PR to explicitly require all dependencies for consistency across detectors. This should make it clearer for users which dependencies are needed when using specific detectors independently.
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.
Updated the PR to add the semantic conventions require to the top-level file while maintaining the individual requires in each detector file.
This should ensure:
require 'opentelemetry-resource-detector-aws'
, all dependencies are loaded properly.require'opentelemetry/resource/detector/aws/ec2'
), they still have all their necessary dependencies.Added some notes to the PR description as well for documentation purposes.