Skip to content

Generate assert function for each metric in mdatagen #12179

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

Merged

Conversation

sincejune
Copy link
Contributor

Description

Completion of #12167 , cc @bogdandrutu

Updated one test to verify the change, will update the rest ones after this PR merges.

Link to tracking issue

n/a

Testing

Added

Documentation

Added

@sincejune sincejune requested review from bogdandrutu, dmitryax and a team as code owners January 24, 2025 12:57
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.80%. Comparing base (df99547) to head (5c68400).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12179      +/-   ##
==========================================
+ Coverage   91.62%   91.80%   +0.18%     
==========================================
  Files         465      465              
  Lines       24775    25342     +567     
==========================================
+ Hits        22699    23266     +567     
  Misses       1687     1687              
  Partials      389      389              

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

metricdatatest.AssertEqual(t, want, got, opts...)
}

// ensure no additional metrics are emitted
require.Equal(t, len(expected), lenMetrics(md))
}

func getMetric(name string, got metricdata.ResourceMetrics) metricdata.Metrics {
{{ range $name, $metric := .Telemetry.Metrics }}
{{ if not $metric.Optional }}
Copy link
Member

Choose a reason for hiding this comment

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

Should we generate for this as well?

FYI: I've never seen a usage of this optional. Can we check if used, otherwise to remove it?

@bogdandrutu bogdandrutu added this pull request to the merge queue Jan 25, 2025
Merged via the queue into open-telemetry:main with commit c2f1599 Jan 25, 2025
53 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jan 26, 2025
…#12184)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
A follow-up PR of #12179 , cc @bogdandrutu 

Note: This PR also removes those metric assertions which is actually
testing metrics that doesn't belong to the package. They might be added
due to the limitation of the AssertMetrics function. e.g. changes in
`processor/memorylimitprocessor/memorylimiter_test.go`

<!-- Issue number if applicable -->
#### Link to tracking issue
Relevant to #12179 

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

<!--Describe the documentation added.-->
#### Documentation
n/a

<!--Please delete paragraphs that you did not use before submitting.-->
sfc-gh-sili pushed a commit to sfc-gh-sili/opentelemetry-collector that referenced this pull request Feb 3, 2025
…12179)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Completion of open-telemetry#12167 , cc @bogdandrutu 

Updated one test to verify the change, will update the rest ones after
this PR merges.
<!-- Issue number if applicable -->
#### Link to tracking issue
n/a

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

<!--Describe the documentation added.-->
#### Documentation
Added
<!--Please delete paragraphs that you did not use before submitting.-->
sfc-gh-sili pushed a commit to sfc-gh-sili/opentelemetry-collector that referenced this pull request Feb 3, 2025
…open-telemetry#12184)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
A follow-up PR of open-telemetry#12179 , cc @bogdandrutu 

Note: This PR also removes those metric assertions which is actually
testing metrics that doesn't belong to the package. They might be added
due to the limitation of the AssertMetrics function. e.g. changes in
`processor/memorylimitprocessor/memorylimiter_test.go`

<!-- Issue number if applicable -->
#### Link to tracking issue
Relevant to open-telemetry#12179 

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

<!--Describe the documentation added.-->
#### Documentation
n/a

<!--Please delete paragraphs that you did not use before submitting.-->
@sincejune sincejune deleted the generate-metric-assert-funcs branch February 11, 2025 12:14
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.

2 participants