opentelemetry-collector
opentelemetry-collector copied to clipboard
[cmd/mdatagen] Add support for optional attribute
Description
Add support for optional attribute, ref: Conditional Required Attribute
Notes:
- Add
helper.tmplfor helper templates - Add
With<AttributeName>EventAttributeandWith<AttributeName>MetricAttributefor optional attributes - Add some helper functions in go files.
Link to tracking issue
Relevant to #12571
Testing
Updated
Documentation
Added
Codecov Report
Attention: Patch coverage is 98.18182% with 2 lines in your changes missing coverage. Please review.
Project coverage is 91.31%. Comparing base (
c9aaed8) to head (055c400). Report is 52 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| cmd/mdatagen/internal/command.go | 92.30% | 0 Missing and 2 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #13007 +/- ##
==========================================
+ Coverage 91.29% 91.31% +0.02%
==========================================
Files 509 509
Lines 28735 28807 +72
==========================================
+ Hits 26233 26305 +72
+ Misses 1988 1986 -2
- Partials 514 516 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
I added some helper functions in the Go files to simplify the templates. I'd like to remove the helper functions if possible, but it doesn't seem to be easy.
Can you please provide a specific use case? The whole point of the attributes defined in the metadata.yaml is to provide end-users visibility on the exact set of attribute being emitted. It's already possible to add any attributes to the generated metrics/event even without this extra API, but this should be strongly discouraged
Can you please provide a specific use case? The whole point of the attributes defined in the metadata.yaml is to provide end-users visibility on the exact set of attribute being emitted. It's already possible to add any attributes to the generated metrics/event even without this extra API, but this should be strongly discouraged
I was working on the PR mentioned below, and I noticed that certain attributes in the events are only pushed when there is an increment in their values. Therefore, I created this PR to introduce optional attributes to address this behavior.
https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/40041/files#diff-e3b3d58b3d3a0c9d1db62068e7c47e72edcaa6409091343ce5ed0e9e48947eebR10
@sincejune, thanks for clarifying, this makes sense to me. Can you please address the comment from @jinja2
This PR was marked stale due to lack of activity. It will be closed in 14 days.