Skip to content

[chore][cmd/mdatagen] Use metadata.yaml as a schema source for references - #15272

Merged
dmitryax merged 12 commits into
open-telemetry:mainfrom
jkoronaAtCisco:mdatagen_external_configs
May 12, 2026
Merged

[chore][cmd/mdatagen] Use metadata.yaml as a schema source for references#15272
dmitryax merged 12 commits into
open-telemetry:mainfrom
jkoronaAtCisco:mdatagen_external_configs

Conversation

@jkoronaAtCisco

Copy link
Copy Markdown
Member

Description

Previously, the schemagen loader used config.schema.yaml as the standalone file format for schema references. This PR changes the source of truth for cross-component schema references to metadata.yaml — the same file that already exists in every component directory.

Instead of parsing a bare ConfigMetadata JSON-schema object, the loader now reads the config: section from a component's metadata.yaml, matching the structure that mdatagen already generates for every component. The generated output is likewise renamed to metadata.yaml (placed under internal/metadata/) and wrapped with the standard metadata.yaml envelope (type, status, config), so it is usable as a reference target by other components in the same way.

Link to tracking issue

Fixes #15259

Testing

Existing unit tests in internal/schemagen and cmd/mdatagen/internal were updated to reflect the new file name and Metadata wrapper format. The persistToFile test was strengthened to verify a full round-trip through loadFromFile. All tests pass.

@jkoronaAtCisco
jkoronaAtCisco requested review from a team and dmitryax as code owners May 7, 2026 17:43
@codspeed-hq

codspeed-hq Bot commented May 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 7 untouched benchmarks
⏩ 76 skipped benchmarks1


Comparing jkoronaAtCisco:mdatagen_external_configs (9341273) with main (e9f60fc)

Open in CodSpeed

Footnotes

  1. 76 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.24%. Comparing base (0afcdf0) to head (9341273).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...datagen/internal/samplescraper/generated_config.go 0.00% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (94.11%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15272      +/-   ##
==========================================
+ Coverage   91.23%   91.24%   +0.01%     
==========================================
  Files         704      704              
  Lines       45926    45948      +22     
==========================================
+ Hits        41899    41926      +27     
+ Misses       2822     2819       -3     
+ Partials     1205     1203       -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.

Comment thread cmd/mdatagen/internal/samplescraper/metadata.yaml
Comment thread cmd/mdatagen/internal/sampleprocessor/internal/metadata/metadata.yaml Outdated
Comment on lines +2 to +9
type: {{.Type}}/metadata
parent: {{.Type}}

status:
disable_codecov_badge: true
class: pkg

config:

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.

Why do we need all this extra yaml? Why cant we generate the exact schema that goes under metrics_config in json format?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That was leftover from my previous attempt to fix this, now as it's no longer needed I cleaned up the template. However I'd like to keep it in yaml as it's better to have it consistent with mdatagen-specific data model for code and docs generation.

@dmitryax dmitryax May 11, 2026

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.

However I'd like to keep it in yaml as it's better to have it consistent with mdatagen-specific data model for code and docs generation

But we need to generate json.schema not ConfigMetadata. We are fortunate they are the same for now, but it's not going to be the case going forward. I don't think we should use it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ConfigMetadata becomes underlying model - the source for json schema, go code and docs. MetricsBuilderConfig becomes part of the config which is relevant for go code and docs as well as for json schema. So that's why I'd like to keep it consistent. At the end I won't output ConfigMetadata anywhere. It's just a working model.

@dmitryax dmitryax May 12, 2026

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.

ConfigMetadata becomes underlying model

Why? Do you want to remove https://github.com/open-telemetry/opentelemetry-collector/blob/main/cmd/mdatagen/internal/templates/config.go.tmpl as the next step? My concern is that generating metadata.yaml from metadata.yaml might be confusing and error prone

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.

I'm merging this PR for now. But we need to address this going forward one way or another

@dmitryax
dmitryax added this pull request to the merge queue May 12, 2026
Merged via the queue into open-telemetry:main with commit c05a471 May 12, 2026
66 of 67 checks passed
swiatekm pushed a commit to swiatekm/opentelemetry-collector that referenced this pull request May 15, 2026
…nces (open-telemetry#15272)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Previously, the schemagen loader used `config.schema.yaml` as the
standalone file format for schema references. This PR changes the source
of truth for cross-component schema references to `metadata.yaml` — the
same file that already exists in every component directory.

Instead of parsing a bare ConfigMetadata JSON-schema object, the loader
now reads the config: section from a component's `metadata.yaml`,
matching the structure that mdatagen already generates for every
component. The generated output is likewise renamed to metadata.yaml
(placed under internal/metadata/) and wrapped with the standard
`metadata.yaml` envelope (type, status, config), so it is usable as a
reference target by other components in the same way.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes open-telemetry#15259

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Existing unit tests in `internal/schemagen` and `cmd/mdatagen/internal`
were updated to reflect the new file name and Metadata wrapper format.
The persistToFile test was strengthened to verify a full round-trip
through loadFromFile. All tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cmd/mdatagen] Use metadata.yaml as a schema source for references

2 participants