[mdatagen] Fix semconv URL validation for metrics with underscores#14584
Open
osullivandonal wants to merge 3 commits intoopen-telemetry:mainfrom
Open
[mdatagen] Fix semconv URL validation for metrics with underscores#14584osullivandonal wants to merge 3 commits intoopen-telemetry:mainfrom
osullivandonal wants to merge 3 commits intoopen-telemetry:mainfrom
Conversation
Currently in mdatagen if you use a url for the semantic_convention: ref: key with a underscore in the anchor tag, mdatagen generate fails. Underscores in the anchor tag of the url is valid for exmaple in system.disk.io_time the anchor tag has: metric-systemdiskio_time The underscore causes an error at generation time. This commit fixes that issue
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14584 +/- ##
==========================================
+ Coverage 91.81% 91.83% +0.01%
==========================================
Files 679 679
Lines 42902 42902
==========================================
+ Hits 39390 39397 +7
+ Misses 2442 2437 -5
+ Partials 1070 1068 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dmathieu
approved these changes
Feb 16, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Currently in mdatagen if you use a url for the semantic_convention: ref: key with a underscore in the anchor tag, mdatagen generate fails. Underscores in the anchor tag of the url is valid for exmaple in system.disk.io_time the anchor tag has:
metric-systemdiskio_time. The underscore causes an error at generation time.Example, in otel-collector-contrib hostmetricsreceiver
metadata.yamlwithsemantic_conventionkey:When running
make generatewe see this error:Link to tracking issue
Fixes #14583
Testing
We can test this out in otel-collector-contrib via updating the
toolsto use this branch locally, for example:In opentelemetry-collector-contrib/internal/tools/go.mod:
Run
go mod tidy.Update metadata for the receiver/hostmetricsreceiver/internal/scraper/diskscraper/metadata.yaml with the semantic_convention ref:
Unit-Tests
A unit test has been added to
loader_test.gothat uses the test file:with_underscore_in_semconv_ref_anchor_tag.yaml.This test has the underscore in the anchor tag and will fail if the regex filters out the underscore.