Skip to content
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

Closed
wants to merge 7 commits into from

Conversation

rogercoll
Copy link
Contributor

Changes

Use semantic conventions statics for Resource keys instead of raw values.

No changes on the code logic.

@rogercoll rogercoll requested a review from a team as a code owner March 8, 2024 16:23
Copy link

codecov bot commented Mar 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.3%. Comparing base (9f0ac7d) to head (8cd8635).

❗ Current head 8cd8635 differs from pull request most recent head bb7ad51. Consider uploading reports for the commit bb7ad51 to get more accurate results

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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

Thanks

Copy link
Member

@cijothomas cijothomas left a 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.

@lalitb
Copy link
Member

lalitb commented Mar 8, 2024

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.

@rogercoll
Copy link
Contributor Author

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.

@TommyCpp
Copy link
Contributor

TommyCpp commented Mar 9, 2024

Since it's only 7 strings I think we can just make them crate public constant inside SDK until semconv stabled

@lalitb
Copy link
Member

lalitb commented Mar 10, 2024

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.

@hdost
Copy link
Contributor

hdost commented Mar 10, 2024

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.

I'd agree, it's mainly from the perspective of API functions/type. It shouldn't affect is there.

@hdost
Copy link
Contributor

hdost commented Mar 10, 2024

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.

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.

@rogercoll
Copy link
Contributor Author

Since it's only 7 strings I think we can just make them crate public constant inside SDK until semconv stabled

Sounds good to me, I will port the resource.rs file from the SemConv crate with only the current used values.

We could look at moving the resourcedectors out into the SemConv crate.

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.).

@cijothomas
Copy link
Member

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.

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.

Pretty much every other language is doing it without issues.

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.

@cijothomas
Copy link
Member

Although, I would keep the SemConv crate free of code's logic and just use it for static data

+1.

@rogercoll rogercoll changed the title feat: use semantic convention static for resource keys feat: use constants for resource detectors keys Mar 12, 2024
@cijothomas
Copy link
Member

@rogercoll
Will discuss this in today's community call and update how to proceed, since there seems to diff. opinions.
Feel free to join, if you'd like, but otherwise, I'll share the decision after the meeting today (~starting in 45 mins)

@cijothomas
Copy link
Member

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
Zhongyang - pub(crate) constants, NOT required to remove ResourceDetectors for Env/OS/Process etc. from SDK at the moment.
Lalit - pub(crate) constants, NOT required to remove ResourceDetectors for Env/OS/Process etc. from SDK at the moment.
Harold - pub(crate) constants, okay to move ResourceDetectors to contrib repo, and keep SDK clean.
Roger - pub(crate) constants,
Python, Golang does keep detectors in SDK -
C++, .NET does not do this.

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)

@rogercoll
Copy link
Contributor Author

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

The SDK MUST extract information from the OTEL_RESOURCE_ATTRIBUTES environment variable and merge this, as the secondary resource, with any resource information provided by the user, i.e. the user provided resource information has higher priority.

@cijothomas
Copy link
Member

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

The SDK MUST extract information from the OTEL_RESOURCE_ATTRIBUTES environment variable and merge this, as the secondary resource, with any resource information provided by the user, i.e. the user provided resource information has higher priority.

yes. it has no semantic convention dependency.

@rogercoll
Copy link
Contributor Author

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?

@TommyCpp
Copy link
Contributor

Given the open-telemetry/opentelemetry-rust-contrib#49 we can remove the resource detector and close this PR?

@rogercoll
Copy link
Contributor Author

@TommyCpp I have just opened a new PR with the agreed changes: #1610

Closing this one.

@rogercoll rogercoll closed this Mar 15, 2024
@TommyCpp
Copy link
Contributor

@TommyCpp I have just opened a new PR with the agreed changes: #1610

Closing this one.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants