You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cmd/mdatagen] Add lint/ordering validation for metadata.yaml (#13782)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### 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)
<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes#13781
<!--Describe what testing was performed and which tests were added.-->
#### Testing
I added tests to validate unordered data and expect an error on it.
```sh
❯ 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]
```
```sh
❯ 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 <[email protected]>
0 commit comments