-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[mdatagen] Re-Aggregate Metric by Attributes #13900
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
base: main
Are you sure you want to change the base?
Changes from 38 commits
4360d05
7c0cf5e
35bbea3
b586ac7
46b4f08
89abc2e
3152269
f446bd7
38e3202
a96aa50
8a34414
a10bce1
a62c37e
cb6f773
22cb283
6370d0b
8c25665
83d6a48
79fc792
a9a4180
6c6ac4b
d3deb99
64ed5c4
e1b8492
9568c45
53f9727
2f088d3
2afb202
a61e0f0
5964165
be95636
de2b34a
70d7548
37ca3d3
af4235f
0de401f
4f8e424
7396a47
2b62d85
e32d0c8
5bcf1a8
7c45208
3cf891e
69f7ba7
4c964c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: 'enhancement' | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver) | ||
component: mdatagen | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: "Add support for metric re-aggregation by disabling attributes in metadata.yaml and user config" | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [10726] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: | ||
|
||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
"strconv" | ||
"strings" | ||
|
||
"go.opentelemetry.io/collector/confmap" | ||
"go.opentelemetry.io/collector/filter" | ||
"go.opentelemetry.io/collector/pdata/pcommon" | ||
) | ||
|
@@ -310,6 +311,13 @@ type Attribute struct { | |
Optional bool `mapstructure:"optional"` | ||
} | ||
|
||
func (a *Attribute) Unmarshal(parser *confmap.Conf) error { | ||
if !parser.IsSet("enabled") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like this is also applied to the resource attributes. The resource attributes with missing I think we should make the |
||
a.Enabled = true | ||
} | ||
return parser.Unmarshal(a) | ||
} | ||
|
||
// Name returns actual name of the attribute that is set on the metric after applying NameOverride. | ||
func (a Attribute) Name() AttributeName { | ||
if a.NameOverride != "" { | ||
|
@@ -343,6 +351,31 @@ func (a Attribute) TestValue() string { | |
return "" | ||
} | ||
|
||
func (a Attribute) TestValueTwo() string { | ||
if len(a.Enum) >= 2 { | ||
return fmt.Sprintf(`%q`, a.Enum[1]) | ||
} | ||
switch a.Type.ValueType { | ||
case pcommon.ValueTypeEmpty: | ||
return "" | ||
case pcommon.ValueTypeStr: | ||
return fmt.Sprintf(`"%s-val-2"`, a.FullName) | ||
case pcommon.ValueTypeInt: | ||
return strconv.Itoa(len(a.FullName) + 1) | ||
case pcommon.ValueTypeDouble: | ||
return fmt.Sprintf("%f", 1.1+float64(len(a.FullName))) | ||
case pcommon.ValueTypeBool: | ||
return strconv.FormatBool(len(a.FullName)%2 == 1) | ||
case pcommon.ValueTypeMap: | ||
return fmt.Sprintf(`map[string]any{"key3": "%s-val3", "key4": "%s-val4"}`, a.FullName, a.FullName) | ||
case pcommon.ValueTypeSlice: | ||
return fmt.Sprintf(`[]any{"%s-item3", "%s-item4"}`, a.FullName, a.FullName) | ||
case pcommon.ValueTypeBytes: | ||
return fmt.Sprintf(`[]byte("%s-val-2")`, a.FullName) | ||
} | ||
return "" | ||
} | ||
|
||
type Signal struct { | ||
// Enabled defines whether the signal is enabled by default. | ||
Enabled bool `mapstructure:"enabled"` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.