Skip to content

Conversation

@ArthurSens
Copy link
Member

Fixes #579

Trying to learn Rust with some good first issues :)

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@ArthurSens ArthurSens requested a review from a team as a code owner January 3, 2026 11:43
}
}
// Try to infer the manifest from the registry path by detecting a
// valid semantic version segment (e.g., v1.26.0) in the path.
Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed the comment here since semver accepts more than just v\d+\.\d+\.\d+, e.g. release candidates

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.1%. Comparing base (8101c01) to head (5d23742).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1108   +/-   ##
=====================================
  Coverage   79.1%   79.1%           
=====================================
  Files        102     102           
  Lines       7943    7963   +20     
=====================================
+ Hits        6284    6306   +22     
+ Misses      1659    1657    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

///
/// * `Some(String)` - The version string including the 'v' prefix (e.g., "v1.26.0")
/// * `None` - If no valid semantic version is found in the path
fn extract_semconv_version(path: &str) -> Option<String> {
Copy link
Contributor

Choose a reason for hiding this comment

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

My only concern here (and also one with the previous regex) is that the v is not required, see: https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/schemas#schema-url

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmmm, gotcha. Reading the link you shared here, it also says that version is always the last part of the URL, so if I'm understanding correctly, I don't need to try to parse every segment and check if it's a valid semver... just the last segment is enough, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the documentation on schema_url is relevant here, because in this context Weaver does not derive a version from a schema_url, but from a semantic conventions registry (local, Git, or archive). For recent registries, Weaver retrieves the version directly from the manifest file, but for older registries this manifest does not exist, and in that case the version is derived from the archive path, for example. See the code of the from_semconv_specs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree we need to be flexible. What I'm saying is that eventually I'd like for SchemaURL to work. Right now it's forcing the v as required, I think we should allow it as optional.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit lost here if in this PR we want to solve v being optional or not 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

If it wasn't optional before, you can leave it as is for now, I'll clean that up in a follow up.

For context - I'm working on new resolution specification where we can resolve "resolved schema" directly from a Schema URL - so I'll need to either merge in your PR and fix in my branch or have you fix it so my local fix doesn't get blown away.

I'd rather merge yours in and fix later if you're nervous about the amount of rust.

Copy link
Contributor

@lquerel lquerel left a comment

Choose a reason for hiding this comment

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

We should change the tests to validate with the real archive URLs.

///
/// * `Some(String)` - The version string including the 'v' prefix (e.g., "v1.26.0")
/// * `None` - If no valid semantic version is found in the path
fn extract_semconv_version(path: &str) -> Option<String> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the documentation on schema_url is relevant here, because in this context Weaver does not derive a version from a schema_url, but from a semantic conventions registry (local, Git, or archive). For recent registries, Weaver retrieves the version directly from the manifest file, but for older registries this manifest does not exist, and in that case the version is derived from the archive path, for example. See the code of the from_semconv_specs.

// Test with GitHub release URL pattern
assert_eq!(
extract_semconv_version(
"https://github.com/open-telemetry/semantic-conventions/releases/download/v1.26.0/semantic-conventions.zip"
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we have a list of file format suffixes that Weaver allows? Semver won't be able to parse those suffixes, so I believe I'll have to manually remove this suffixes before parsing the version

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
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.

Replace the regex in from_semconv_specs with the https://docs.rs/semver/latest/semver/ crate.

3 participants