Skip to content
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

mdatagen: get package name from metadata #11468

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

braydonk
Copy link
Contributor

@braydonk braydonk commented Oct 16, 2024

Description

I noticed a mistake in my previous PR #11232; some function calls did not pass the correct package name in (passing in "metadata" instead of the intended generated package name). This PR attempts to address the potential for this mistake to even occur by providing a wrapper generateFile function that automatically uses the generated package name from the metadata. The original version of the function that accepts a package name is intact for the templates that are going in the base package instead of the generated one.

Link to tracking issue

Bug originally from #11231
Fixes #11469

Testing

make mdatagen-test

Also added a custom generated package to the sample components, which would have caught the original bug.

Documentation

@braydonk braydonk requested a review from a team as a code owner October 16, 2024 13:31
@braydonk braydonk requested a review from codeboten October 16, 2024 13:31
I noticed a mistake in my previous PR open-telemetry#11232; some function calls did
not pass the correct package name in (passing in "metadata" instead of
the intended generated package name). This PR attempts to address the
potential for this mistake to even occur by providing a wrapper
`generateFile` function that automatically uses the generated package
name from the metadata. The original version of the function that
accepts a package name is intact for the templates that are going in the
base package instead of the generated one.
@braydonk braydonk force-pushed the mdatagen_fix_package_name branch from 3cd7f36 to a7da76a Compare October 16, 2024 13:37
@braydonk
Copy link
Contributor Author

I believe this change should not need a changelog. It is a fix for a bug that never made it into a release, and otherwise provides no user-visible changes.

Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 87.15084% with 69 lines in your changes missing coverage. Please review.

Project coverage is 91.35%. Comparing base (b9ff1bc) to head (64faf62).
Report is 201 commits behind head on main.

Files with missing lines Patch % Lines
...amplereceiver/internal/custom/generated_metrics.go 91.83% 27 Missing and 2 partials ⚠️
...plereceiver/internal/custom/generated_telemetry.go 63.79% 21 Missing ⚠️
...samplereceiver/internal/custom/generated_config.go 82.85% 8 Missing and 4 partials ⚠️
...mplereceiver/internal/custom/generated_resource.go 91.11% 4 Missing ⚠️
cmd/mdatagen/internal/command.go 66.66% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11468      +/-   ##
==========================================
- Coverage   91.43%   91.35%   -0.09%     
==========================================
  Files         447      451       +4     
  Lines       23745    24275     +530     
==========================================
+ Hits        21712    22176     +464     
- Misses       1657     1717      +60     
- Partials      376      382       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@braydonk
Copy link
Contributor Author

The new coverage issue are just for the generated custom package I added, which I don't think are any more/less covered than the other generated metadata package and are just there as goldens anyway. So I think the codecov can be accepted.

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Nov 12, 2024
@braydonk
Copy link
Contributor Author

Unstale, looks like this fell through the cracks before the original feature got merged. I'll introduce a changelog since this now fixes a released feature.

@github-actions github-actions bot removed the Stale label Nov 13, 2024
@mx-psi mx-psi self-requested a review November 21, 2024 15:47
Comment on lines 5 to 6
//go:generate mdatagen metadata.yaml
//go:generate mdatagen metadata_custom.yaml
Copy link
Member

Choose a reason for hiding this comment

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

Let's avoid the duplication. Maybe having a custom package in the processor and leaving the receiver as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opted to remove duplication slightly differently in f106762.

I left the custom package in samplereceiver. This still ensures the extent of coverage:

  • Generates the representative set of templates for a metadata package
  • Demonstrates the capability of generating two separate packages with different names

The custom package in sampleprocessor was not adding anything to the above coverage by just doing it in samplereceiver, so I removed that. I think the current duplication is acceptable since it still provides the necessary coverage, but if you disagree I can change it.

Copy link
Member

Choose a reason for hiding this comment

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

I still don't understand why we need two packages for the same receiver. This will be confusing to maintain going forward. Also, we need to show how mdatagen is supposed to be used. Having two yaml files and two packages for the same module is not something we should recommend. Can we just add generated_package_name to the existing yaml for the receiver and move the package to a custom path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having two yaml files and two packages is the reason the custom package name feature was added in the first place. It was the only reasonable way I could see for a receiver to have a featuregated semantic convention transition, as doing it within one metadata package seems infeasible based on my attempts. We wouldn't want two packages to exist forever, but for the lifetime of the featuregate (which for a semconv transition will likely be a longer horizon) two packages would need to coexist.

@braydonk braydonk requested a review from dmitryax November 27, 2024 15:09
scope_name: go.opentelemetry.io/collector/internal/receiver/samplereceiver
github_project: open-telemetry/opentelemetry-collector

generated_package_name: custom
Copy link
Member

Choose a reason for hiding this comment

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

internal/metadata package is abandoned now and should be removed, right?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added Stale and removed Stale labels Dec 18, 2024
Copy link
Contributor

github-actions bot commented Jan 5, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jan 22, 2025
@braydonk
Copy link
Contributor Author

Not stale, still relevant for open-telemetry/opentelemetry-collector-contrib#35325

I'll wait until knowing the change isn't rejected to fix the conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mdatagen: using the wrong package name for a generateFile call
4 participants