-
Notifications
You must be signed in to change notification settings - Fork 600
feat: export SDK crate version as constant #2504
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
Closed
the-wondersmith
wants to merge
3
commits into
open-telemetry:main
from
the-wondersmith:feat/opentelemetry-sdk/version-number-constant
Closed
Changes from 1 commit
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
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.
we try to keep public API as lean as possible, so unless there is a strong reason to expose this, we should not.
Users rarely need this as this is automatically populated.
Uh oh!
There was an error while loading. Please reload this page.
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.
FWIW, my specific usecase involves setting the value of
telemetry.sdk.version(as defined inopentelemetry_semantic_conventions), e.x.:Specifically, that's in a library crate intended for use in other "actual" crates to simplify setting up
tracingwith export to an OTLP collector, so it's a layer removed even from theopentelemetry_sdkcrate itself and users are likely to not even be pulling in the sdk crate themselves, so I can't really have them supply it.Including this simple constant just makes it much easier to "stay in line" with the defined convention without having to constantly remember to update that static string whenever the SDK version changes. Plus,
cargodoes do a certain amount of fudging with version numbers, so unless I pin explicitly to something likeopentelemetry_sdk = "= 0.27.0"the actual version of the SDK that ends up getting used could be anything in the0.27.*range. Much easier and more reliable to just... export a simple string constant, don't you think? 😅Oh, and not to potentially talk past the close, but this simple constant won't meaningfully inflate the "weight" of the crate's public API at all - unless it's explicitly used in some downstream crate it won't be included in compiled binaries. In terms of compile-time overhead, cargo takes the time to determine and set that value unconditionally, so it's no extra overhead there either 🙂
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.
@cijothomas ^bump 🙂
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.
@cijothomas ^bump 🙃
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.
Sorry was busy with few other issues, will recheck today, thanks for reminder!
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.
No problem at all! Thank you for taking the time 😅
Uh oh!
There was an error while loading. Please reload this page.
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-wondersmith Can you use TelemetryResourceDetector to populate the otel-sdk version? As an example here -
opentelemetry-rust/opentelemetry-prometheus/tests/integration_test.rs
Lines 365 to 371 in 8520610
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.
@lalitb Yup, sure can! 😁