Skip to content

Conversation

@ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Sep 30, 2025

Description

This PR adds support in mdatagen for defining SemConv reference for metrics.

Enhancing your metrics/signals in metadata.yaml like bellow:

metrics:
  system.cpu.time:
    enabled: true
    stability:
      level: beta
    description: Monotonic cumulative sum int metric enabled by default.
    unit: s
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    semantic_convention:
      semconv_ref: https://github.com/open-telemetry/semantic-conventions/blob/v1.37.0/docs/system/system-metrics.md#metric-systemcputime

Will provide the following generated docs:

system.cpu.time

Monotonic cumulative sum int metric enabled by default.

Unit Metric Type Value Type Aggregation Temporality Monotonic Stability Semantic Convention
s Sum Int Cumulative true beta system.cpu.time

Validation is added so as to ensure that provided SemConv urls match the top_level semconv version as well as the metric's name.

Link to tracking issue

Related to #13910 and #13297.

Testing

Tuned

Documentation

Tuned

@codecov
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 94.05941% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.27%. Comparing base (6f29b34) to head (2442bf8).

Files with missing lines Patch % Lines
cmd/mdatagen/internal/metric.go 77.77% 3 Missing and 3 partials ⚠️

❌ Your patch check has failed because the patch coverage (94.05%) 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   #13920   +/-   ##
=======================================
  Coverage   92.27%   92.27%           
=======================================
  Files         657      657           
  Lines       41111    41207   +96     
=======================================
+ Hits        37936    38025   +89     
- Misses       2173     2177    +4     
- Partials     1002     1005    +3     

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

@ChrsMark ChrsMark changed the title [mdatagen] Add semconv reference for signals in metadata schema [mdatagen] Add semconv reference for metrics in metadata schema Sep 30, 2025
@ChrsMark ChrsMark force-pushed the mdatagen_add_semconv_ref branch from ea7e141 to 51d5532 Compare September 30, 2025 15:09
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

i like this change a lot. would be great to get this in

@ChrsMark
Copy link
Member Author

i like this change a lot. would be great to get this in

I'll get back into finalising this and opening for review soonish!

@ChrsMark ChrsMark force-pushed the mdatagen_add_semconv_ref branch 5 times, most recently from c46a42c to c156b07 Compare October 30, 2025 11:24
@ChrsMark ChrsMark marked this pull request as ready for review October 30, 2025 11:27
@ChrsMark ChrsMark requested review from a team and dmitryax as code owners October 30, 2025 11:27
@ChrsMark ChrsMark force-pushed the mdatagen_add_semconv_ref branch from c156b07 to fe3a27c Compare October 30, 2025 13:11
@ChrsMark
Copy link
Member Author

@codeboten @mx-psi I've opened this for review now. Feel free to take a look when you get the chance, thank's!

}

type SemanticConvention struct {
SemanticConventionRef string `mapstructure:"semconv_ref"`
Copy link
Member

Choose a reason for hiding this comment

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

I think the semconv_ prefix here is redundant since this is already in the semantic_convention section.

GeneratedPackageName: "metadata",
Type: "sample",
SemConvVersion: "1.9.0",
SemConvVersion: "1.37.0",
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what this field is, but it seems like we should either drop this or make sure that sem_conv_version and the version linked in semconv_ref are aligned somehow

Copy link
Member Author

Choose a reason for hiding this comment

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

This is sth that already exists and links the whole component to a specific version of SemConv. It's not really used apart from a few places inside the templates that mdatagen populates i.e. logs.go.tmpl and metrics.go.tmpl.

The PR comes with a pattern checking that also verifies if the provided reference's version matches with this generic one: https://github.com/open-telemetry/opentelemetry-collector/pull/13920/files#diff-b33d4fa1a4595583d310c0a381ce3849aefb42419451584fd0e1c43bd16f5263R124-R128. (also covered by this test)

Copy link
Member

Choose a reason for hiding this comment

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

Okay, sorry, another thing I missed. I think that makes sense, though maybe we can remove it entirely if it's not widely used?

I am worried that we won't be able to support transition scenarios where we want to target two semconv versions

Signed-off-by: ChrsMark <[email protected]>
songy23 pushed a commit to open-telemetry/opentelemetry-collector-contrib that referenced this pull request Oct 30, 2025
This patch adds the missing stability definition for the
`elasticsearch.node.open_files` metric.

Spotted at
open-telemetry/opentelemetry-collector#13920.

Signed-off-by: ChrsMark <[email protected]>
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.

3 participants