[mdatagen] Mdatagen link metrics and attributes from metadata to semconv#14598
Conversation
This allows metrics defined in the metadata file to directly use the defined semantic convention for that metric.
This is to test mdatagen to generate the correct attribute for semconv
When the semantic_convention: ref url is provided mdatagen now infers the pkg and type from that url. This only works for semconv >= v1.32.0 due to the generated go code only containing the semconv types from this version and above.
…tadata-to-semconv
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (92.71%) 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 #14598 +/- ##
========================================
Coverage 91.83% 91.84%
========================================
Files 679 679
Lines 42921 43063 +142
========================================
+ Hits 39416 39550 +134
- Misses 2437 2442 +5
- Partials 1068 1071 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…tadata-to-semconv
…tadata-to-semconv
…tadata-to-semconv
…tadata-to-semconv
Merging this PR will not alter performance
|
These have been removed as we don't want the consumer to have to manually specify this, mdatagen can infer thse directly from the semantic_convention ref url.
|
Closing this PR for now as the direction for this work has changed slightly. This PR also found an issue with using the approach of using the semconv go sdk to generate code using semconv go code, semconv version of >= 1.32.0. There is an open PR to update the attributes in the metadata schema with the semantic_convention ref, which this work doesn't tackle. #14646 |
Description
This PR add's support for linking metrics defined in metadata.yaml to their Semantic Conventions definitions. When a metric specifies a
semantic_convention.refURL, the generated code will:systemconv)system.cpu.time→systemconv.CPUTime)This enables components to leverage stable semantic convention definitions directly, ensuring consistency with the OTel specification.
For example, if we use the
semantic_convention.refurl forsystem.memory.limit:The generated code from running
make gogenerate:Before this update to mdatagen:
After using this PR to generate code
Link to tracking issue
Fixes #13297
Testing
InferSemConvFromMetricNamecovering various metric name patternsinferSemConvTypesto verify auto-population of Package/Typesystem.cpu.time,system.memory.limit) to verify end-to-end code generationDocumentation
metadata-schema.yamlwith documentation for thesemantic_conventionfieldrefis provided