Skip to content

[cmd/mdatagen] Add lint/ordering validation for metadata.yaml#13782

Merged
dmitryax merged 16 commits into
open-telemetry:mainfrom
paulojmdias:feat/13781
Oct 17, 2025
Merged

[cmd/mdatagen] Add lint/ordering validation for metadata.yaml#13782
dmitryax merged 16 commits into
open-telemetry:mainfrom
paulojmdias:feat/13781

Conversation

@paulojmdias
Copy link
Copy Markdown
Member

@paulojmdias paulojmdias commented Sep 6, 2025

Description

Extend mdatagen to validate that keys in metadata.yaml files are alphabetically sorted (resource_attributes, attributes, metrics, events, and telemetry.metrics).

The idea came from open-telemetry/opentelemetry-collector-contrib#42477 (comment)

Link to tracking issue

Fixes #13781

Testing

I added tests to validate unordered data and expect an error on it.

❯ mdatagen metadata.yaml
Error: metadata.yaml ordering check failed: [telemetry metrics] keys are not sorted: [metric1 metric0]
Error: metadata.yaml ordering check failed: [telemetry metrics] keys are not sorted: [metric1 metric0]
❯ mdatagen metadata.yaml
Error: metadata.yaml ordering check failed: [resource_attributes] keys are not sorted: [cloud.region cloud.availability_zone cloud.provider host.id host.name]
Error: metadata.yaml ordering check failed: [resource_attributes] keys are not sorted: [cloud.region cloud.availability_zone cloud.provider host.id host.name]

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
@paulojmdias paulojmdias marked this pull request as ready for review September 6, 2025 08:42
@paulojmdias paulojmdias requested review from a team and dmitryax as code owners September 6, 2025 08:42
@paulojmdias paulojmdias marked this pull request as draft September 6, 2025 08:54
paulojmdias and others added 2 commits September 6, 2025 12:22
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 6, 2025

Codecov Report

❌ Patch coverage is 83.01887% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.59%. Comparing base (266beca) to head (ee2eba5).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
cmd/mdatagen/internal/command.go 83.01% 6 Missing and 3 partials ⚠️

❌ Your patch status has failed because the patch coverage (83.01%) 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   #13782      +/-   ##
==========================================
- Coverage   91.61%   91.59%   -0.02%     
==========================================
  Files         655      655              
  Lines       42729    42782      +53     
==========================================
+ Hits        39147    39188      +41     
- Misses       2761     2769       +8     
- Partials      821      825       +4     

☔ 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.

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Sep 23, 2025
@paulojmdias
Copy link
Copy Markdown
Member Author

/label -stale never-stale

@github-actions github-actions Bot removed the Stale label Sep 24, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 9, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions Bot added the Stale label Oct 9, 2025
@dmitryax
Copy link
Copy Markdown
Member

dmitryax commented Oct 9, 2025

The proposal LGTM. @paulojmdias are you planning to finalize the PR?

@dmitryax dmitryax removed the Stale label Oct 9, 2025
@paulojmdias
Copy link
Copy Markdown
Member Author

@dmitryax yes, I will work into it soon

paulojmdias and others added 5 commits October 10, 2025 23:07
… into feat/13781

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
@paulojmdias paulojmdias marked this pull request as ready for review October 10, 2025 22:30
@paulojmdias
Copy link
Copy Markdown
Member Author

@dmitryax I think you can review now.

All the reordering of metadata.yaml files are on this PR, but please let me know if you prefer to move it into a different PRs.

The contrib_tests are expected to fail, as a lot of metadata.yaml files are not properly sorted.

The changelog pipeline failure will be fixed in #14000

Copy link
Copy Markdown
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

Do you have any script or temporary command to update existing files? It'll be painful to sort all the metadata.yaml files in contrib manually

Comment thread cmd/mdatagen/internal/command.go Outdated
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
…3465)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
…43450)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
#43454)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
…tries (#43446)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
…43445)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
atoulme pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 14, 2025
…43441)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
@paulojmdias
Copy link
Copy Markdown
Member Author

paulojmdias commented Oct 14, 2025

@dmitryax, as all the sort PRs on the contrib side were already merged, and the tests are ok now, this PR could be safely reviewed 🙏

Copy link
Copy Markdown
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Ideally we would instead turn this section into a list, since map keys do not have an order in YAML which in practice means that YAML tooling may reorder these as they please

Given that this is underway we can finish with the current batch of PRs on contrib and just file an issue about this and handle it later?

@paulojmdias
Copy link
Copy Markdown
Member Author

Ideally we would instead turn this section into a list, since map keys do not have an order in YAML which in practice means that YAML tooling may reorder these as they please

Given that this is underway we can finish with the current batch of PRs on contrib and just file an issue about this and handle it later?

To be on the same page, the idea is to merge all the contrib PRs and close this one, or merge this one and open a new issue to transform everything into a list later on?

@mx-psi
Copy link
Copy Markdown
Member

mx-psi commented Oct 17, 2025

Ideally we would instead turn this section into a list, since map keys do not have an order in YAML which in practice means that YAML tooling may reorder these as they please
Given that this is underway we can finish with the current batch of PRs on contrib and just file an issue about this and handle it later?

To be on the same page, the idea is to merge all the contrib PRs and close this one, or merge this one and open a new issue to transform everything into a list later on?

We can merge all contrib PRs, merge this one and file an issue to deal with what I mentioned

@paulojmdias
Copy link
Copy Markdown
Member Author

@mx-psi LGTM 👍

codeboten pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 17, 2025
)

#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
codeboten pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 17, 2025
#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
dmitryax pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 17, 2025
#### Description

Sort metadata.yaml file in preparation for sort validation using
mdatagen. Context:
open-telemetry/opentelemetry-collector#13782

Signed-off-by: Paulo Dias <paulodias.gm@gmail.com>
Copy link
Copy Markdown
Member

@dmitryax dmitryax left a comment

Choose a reason for hiding this comment

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

@paulojmdias please rebase. It should fix the CI I hope

@paulojmdias
Copy link
Copy Markdown
Member Author

@dmitryax already did. Now I will only expect to fail due to the Merge freeze.

Should I improve something to make CodeCov better?

@dmitryax
Copy link
Copy Markdown
Member

Should I improve something to make #13782 (comment) better?

It's fine. Coverage of the mdatagen command isn't that important as the collector code

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.

Add lint/ordering validation for metadata.yaml in mdatagen

4 participants