Skip to content

Access names from mdatagen generated metrics #12459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
braydonk opened this issue Feb 22, 2025 · 2 comments · Fixed by #12531
Closed

Access names from mdatagen generated metrics #12459

braydonk opened this issue Feb 22, 2025 · 2 comments · Fixed by #12531
Labels
cmd/mdatagen help wanted Good issue for contributors to OpenTelemetry Service to pick up

Comments

@braydonk
Copy link
Contributor

Component(s)

cmd/mdatagen

Describe the issue you're reporting

I have a use case where I'm trying to produce a configuration validation error for a receiver that intends to reference a particular metric name. In particular the scenario is if a particular technology is disabled but a particular metric that requires that subsystem is enabled, I want to produce an error like:

Metric metric.name requires subsystem to be enabled

What would be great would be to reference the name directly from the mdatagen generated package, as putting the metric name directly in the error isn't future-proof against the metric name changing.

I have no particular preference for what this API looks like, provided it allows me to access any metric or resource attribute names. If there already is a way to do this and I've missed it, I will close this issue.

Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@dmitryax
Copy link
Member

Sounds reasonable to expose that. AFAIR we already need this in some other scrapers

@dmitryax dmitryax added the help wanted Good issue for contributors to OpenTelemetry Service to pick up label Feb 23, 2025
github-merge-queue bot pushed a commit that referenced this issue Apr 2, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Add variable for metric name in mdatagen, accessing via
`metadata.MetricsInfo.<metric-variable>.Name`

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #12459 

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

<!--Describe the documentation added.-->
#### Documentation
Added

<!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/mdatagen help wanted Good issue for contributors to OpenTelemetry Service to pick up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants