Skip to content

feat(api): add StringValue::from_static_str#3540

Open
juchiast wants to merge 6 commits into
open-telemetry:mainfrom
juchiast:const-string
Open

feat(api): add StringValue::from_static_str#3540
juchiast wants to merge 6 commits into
open-telemetry:mainfrom
juchiast:const-string

Conversation

@juchiast

@juchiast juchiast commented Jun 7, 2026

Copy link
Copy Markdown

Changes

Add StringValue::from_static_str, make it possible to create a StringValue at compile time.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

juchiast added 2 commits June 8, 2026 00:59
Make it possible to create a StringValue at compile time
@juchiast juchiast requested a review from a team as a code owner June 7, 2026 18:03
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 7, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.


impl StringValue {
/// Create a new const `StringValue`.
pub const fn from_static_str(value: &'static str) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we add a small doctest showing the actual const use case here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Unfortunately, we can't make a KeyValue at compile time with the current initializer. I changed the example.

@juchiast juchiast changed the title Add StringValue::from_static_str feat(api): add StringValue::from_static_str Jun 8, 2026
impl StringValue {
/// Create a new const `StringValue`.
///
/// This is useful for making static label values:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let labels = &[KeyValue::new("key", "value")];

^ couldn't we already this today?

@github-actions

Copy link
Copy Markdown

Thank you for your contribution! This PR has been automatically marked as stale because it has not had activity in the last 14 days. This may be due to a delay in review on our side or awaiting a response from you; either is fine, and we appreciate your patience.

It will be closed in 14 days if no further activity occurs. Pushing a new commit or leaving a comment will remove the stale label and keep the PR open.

@github-actions github-actions Bot added the Stale label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants