Skip to content

[mdatagen] missing imports after running make generate #13069

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

Open
kaiyan-sheng opened this issue May 21, 2025 · 2 comments
Open

[mdatagen] missing imports after running make generate #13069

kaiyan-sheng opened this issue May 21, 2025 · 2 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@kaiyan-sheng
Copy link

kaiyan-sheng commented May 21, 2025

Component(s)

cmd/mdatagen

What happened?

Describe the bug
When a new metric is added into metadata.yaml file and make generate is ran, I can see multiple files generated by mdatagen. But one of the files internal/metadataset/generated_telemetrytest_test.go is missing an import:
Image

Steps to reproduce

  1. add a metric in metadata.yaml
  2. run make generate
  3. you can check Use mdatagen to add a telemetry metric kaiyan-sheng/opentelemetry-collector-components#1 as an example for the missing import

The workaround is to run goimports after the make generate command. But it would be nice to have mdatagen to take care of the imports directly.

What did you expect to see?
I expect to see "github.com/elastic/opentelemetry-collector-components/processor/ratelimitprocessor/internal/metadata" in the import list.

What did you see instead?
Missing import instead.

Collector version

v0.125.0

Environment information

Environment

OS: macOS 15.4.1
Compiler(if manually compiled): go 1.23.8

@kaiyan-sheng kaiyan-sheng added the bug Something isn't working label May 21, 2025
@sincejune
Copy link
Contributor

@kaiyan-sheng To resolve this issue quickly, you can run make gogenerate, which will correctly add the missing imports.

Since this is a Go template-based module, it's quite challenging to conditionally track all the imports. We've encountered similar issues frequently. However, feel free to open a PR to address this problem!

@sincejune sincejune added the good first issue Good for newcomers label May 21, 2025
@kingbj940429
Copy link

Can I work this? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants