Commit 7c31dd5
authored
[mdatagen] bug fix - reaggreagate_set test generation (#14441)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixes reaggregation test generation when metrics have attributes with
`requirement_level: required`.
1. **Config validation failure**: The generated `testdata/config.yaml`
included `attributes: []` in the `reaggregate_set` section, but required
attributes must always be present. This caused config validation to fail
with an error like:
```
error decoding 'metrics': attributes [required_string_attr] are required for metric reaggregate.metric.with_required
```
**Fix**: Updated `config.yaml.tmpl` to use `requiredAttributes` helper
to include required attributes in the `reaggregate_set` config instead
of an empty array.
2. **Test assertion failure**: The generated `metrics_test.go` used
different values for required attributes across data points, preventing
them from merging during reaggregation. The test expected 1 data point
but received 2.
**Fix** - Updated `metrics_test.go.tmpl` to use the same value for
required attributes across both data points in reaggregation tests,
allowing them to merge correctly while still testing that non-required
attributes are dropped.
<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #
<!--Describe what testing was performed and which tests were added.-->
#### Testing
- Added `required_string_attr` attribute and
`reaggregate.metric.with_required` metric to
`samplereceiver/metadata.yaml` to cover this scenario
<!--Please delete paragraphs that you did not use before submitting.-->1 parent ba17669 commit 7c31dd5
File tree
10 files changed
+296
-49
lines changed- cmd/mdatagen/internal
- samplereceiver
- internal/metadata
- testdata
- templates
- testdata
10 files changed
+296
-49
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
247 | 255 | | |
248 | 256 | | |
249 | 257 | | |
| |||
267 | 275 | | |
268 | 276 | | |
269 | 277 | | |
270 | | - | |
| 278 | + | |
271 | 279 | | |
272 | 280 | | |
273 | 281 | | |
| |||
276 | 284 | | |
277 | 285 | | |
278 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
279 | 299 | | |
280 | 300 | | |
281 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
81 | 97 | | |
82 | 98 | | |
83 | 99 | | |
| |||
Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 141 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments