Skip to content

Commit 92d7303

Browse files
authored
[cmd/mdatagen] Do not generate redundant reaggregation config options (#14689)
Do not generate the following metrics re-aggregation config options for metrics that don't have any attributes that can be aggregated: - `attributes` - `aggregation_strategy`
1 parent e2ff1ad commit 92d7303

23 files changed

Lines changed: 284 additions & 644 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: cmd/mdatagen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Skip generating reaggregation config options for metrics that have no aggregatable attributes.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14689]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [user]

.github/workflows/utils/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"version": "0.2",
33
"language": "en",
44
"words": [
5+
"aggregatable",
56
"Alolita",
67
"Andrzej",
78
"Anoshin",

cmd/mdatagen/internal/command.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ func templatize(tmplFile string, md Metadata) *template.Template {
260260
}
261261
return atts
262262
},
263+
"hasAggregatableAttributes": func(ans []AttributeName) bool {
264+
for _, an := range ans {
265+
if md.Attributes[an].RequirementLevel == AttributeRequirementLevelRecommended ||
266+
md.Attributes[an].RequirementLevel == AttributeRequirementLevelOptIn {
267+
return true
268+
}
269+
}
270+
return false
271+
},
263272
"getEventConditionalAttributes": func(attrs map[AttributeName]Attribute) []AttributeName {
264273
seen := make(map[AttributeName]bool)
265274
used := make([]AttributeName, 0)

cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_config.go

Lines changed: 36 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_config_test.go

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_metrics.go

Lines changed: 4 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_metrics_test.go

Lines changed: 13 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/mdatagen/internal/sampleconnector/internal/metadata/testdata/config.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ all_set:
66
attributes: ["string_attr","state","enum_attr","slice_attr","map_attr"]
77
default.metric.to_be_removed:
88
enabled: true
9-
attributes: []
109
metric.input_type:
1110
enabled: true
1211
attributes: ["string_attr","state","enum_attr","slice_attr","map_attr"]
@@ -43,7 +42,6 @@ reaggregate_set:
4342
attributes: []
4443
default.metric.to_be_removed:
4544
enabled: true
46-
attributes: []
4745
metric.input_type:
4846
enabled: true
4947
attributes: []
@@ -80,7 +78,6 @@ none_set:
8078
attributes: ["string_attr","state","enum_attr","slice_attr","map_attr"]
8179
default.metric.to_be_removed:
8280
enabled: false
83-
attributes: []
8481
metric.input_type:
8582
enabled: false
8683
attributes: ["string_attr","state","enum_attr","slice_attr","map_attr"]

0 commit comments

Comments
 (0)