Commit 7565af8
committed
[mdatagen] Fix invalid test code generation for conditionally_required enum attributes
When an attribute has requirement_level: conditionally_required and an enum
type, the generated metrics_test.go was passing the enum constant directly
(an integer) to With{Attr}MetricAttribute(), which expects a string. This
caused compile errors in generated test code.
Fix by introducing a getConditionalAttributeValue template helper that
appends .String() to enum attribute constants, producing the correct string
type. Also fix config.go.tmpl to only import "slices" when there are
actually required attributes in reaggregation metrics, avoiding unused
import compile errors.
Add assertions for conditionally_required attributes in the reaggregation
branch of metrics_test.go.tmpl so the generated tests verify their presence
and value, matching the pattern used in the non-reaggregation branch.
Add TestDeprecatedRecordMethods to exercise the deprecated
MetricsBuilder.Record*DataPoint wrapper methods that exist for backward
compatibility when metrics have entities. The existing test only exercised
the entity builder path, leaving lines in generated_metrics.go uncovered
and failing the Codecov patch coverage gate.
Restore stdlib/third-party/local import group separation in generated
files to satisfy impi linter rules.
Regenerate sampleconnector and sampleentityreceiver fixtures.
Resolves #14196
Signed-off-by: Kc Balusu <kcbalusu@meta.com>1 parent 346b065 commit 7565af8
10 files changed
Lines changed: 135 additions & 34 deletions
File tree
- cmd/mdatagen/internal
- sampleconnector
- internal/metadata
- sampleentityreceiver/internal/metadata
- samplereceiver/internal/metadata
- templates
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments