-
Notifications
You must be signed in to change notification settings - Fork 502
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
feat: use constants for resource detectors keys #1610
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1610 +/- ##
=======================================
- Coverage 68.3% 67.3% -1.0%
=======================================
Files 139 138 -1
Lines 19806 19656 -150
=======================================
- Hits 13530 13245 -285
- Misses 6276 6411 +135 ☔ View full report in Codecov by Sentry. |
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
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.
We need to plan this further before accepting.
SemanticConventions for most of the Resource is experimental : https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/os.md#operating-system
So the semantic conventions crate would also likely remain experimental (or we split it to multiple or feature flags). Having SDK take a dependency on that can impact SDK's own stable release.
I think using constants from the semantic conventions crate instead of hardcoding strings is a safe bet. Any updates to these constants (eg deprecated/removed) shouldn't impact our SDK's API. Pretty much every other language is doing it without issues. |
Good point, I see that other SDK's use the semconv statics as well, but at the same time, their API version is aligned with the semconv version too. The Go SDK is stable, but using the OS experimental SemanticConventions. The same happens in the Python SKD. While most semantic conventions attributes are not stable, their deprecation won't affect the current API. |
Since it's only 7 strings I think we can just make them crate public constant inside SDK until semconv stabled |
Makes sense to have public constants within SDK as an interim solution if we don't want to have dependency on semconv till it is stable. |
I'd agree, it's mainly from the perspective of API functions/type. It shouldn't affect is there. |
We could look at moving the resourcedectors out into the SemConv crate. |
Sounds good to me, I will port the resource.rs file from the SemConv crate with only the current used values.
Although, I would keep the SemConv crate free of code's logic and just use it for static data, it could really fit with a resource detection feature flag (to avoid unneeded dependencies, etc.). |
If semantic conventions changes, user was relying on SDK to provide resource detectors, it is breaking the behavior. Agree it is not the SDK's APIs breaking, but behavior breaking.
I doubt that. The "without issues." part! When semantic convention makes a breaking change, it'll be affecting SDK users. The conventions may not have changed that much, but we shouldn't rely on that. SDK crate should not be in the job of providing resource detectors, other than the ones required by spec which is only telemetry and service (both are stable already. Everything else should be moved out of sdk to own crates. |
+1. |
Do not use the SemConv crate until stable.
@rogercoll |
From Mar 12 2024, Community discussion: Cijo - pub(crate) constants, Remove all non-spec mandated ResourceDetectors from SDK, and make a new -contrib crate for that Roger to create a new crate in contrib repo and move all detectors from SDK (the non-spec mandated ones - telemetry, service) to that new crate. Make it easy for users to discover the new home. https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/README.md#semantic-attributes-with-sdk-provided-default-value - the ones we need to keep in sdk. (4 constants) |
In addition to the telemetry and service ones, I think we should keep the environment one too: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable
|
yes. it has no semantic convention dependency. |
PR regarding the migration of the OS and process detectors to the contrib crate: open-telemetry/opentelemetry-rust-contrib#49 Your feedback will be greatly appreciated. Should we proceed with the sdk removal once the new crate is available in the contrib? |
Given the open-telemetry/opentelemetry-rust-contrib#49 we can remove the resource detector and close this PR? |
Sorry I realize I may be misleading on the previous comment. I meant we can remove the resrouce detector and this PR should be good to merge. Can we reopen this one? If you prefer we can also review and merge the new one. |
Changes
Use semantic conventions statics for Resource keys instead of raw values.
No changes on the code logic.