[mdatagen] Re-Aggregate Metric by Attributes#13431
Conversation
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (58.21%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #13431 +/- ##
==========================================
- Coverage 92.44% 91.70% -0.74%
==========================================
Files 630 630
Lines 35515 36141 +626
==========================================
+ Hits 32832 33144 +312
- Misses 2135 2422 +287
- Partials 548 575 +27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
64e3dfc to
b8282b3
Compare
rogercoll
left a comment
There was a problem hiding this comment.
Code looks good to me, thanks for working on this 🚀
da870bc to
ca1d369
Compare
9a15932 to
09f9aff
Compare
| assert.Equal(t, map[string]any{"key1": "map_attr-val1", "key2": "map_attr-val2"}, attrVal.Map().AsRaw()) | ||
| if !mb.config.Attributes.MapAttr.Enabled { | ||
| assert.False(t, ok) | ||
| assert.Equal(t, "", attrVal.Map().AsRaw()) |
| @@ -101,6 +104,15 @@ func TestMetricsBuilder(t *testing.T) { | |||
| allMetricsCount++ | |||
| mb.RecordDefaultMetricDataPoint(ts, 1, "string_attr-val", 19, AttributeEnumAttrRed, []any{"slice_attr-item1", "slice_attr-item2"}, map[string]any{"key1": "map_attr-val1", "key2": "map_attr-val2"}, WithOptionalIntAttrMetricAttribute(17), WithOptionalStringAttrMetricAttribute("optional_string_attr-val")) | |||
There was a problem hiding this comment.
After this call, we can loop over the attributes (using go templates), and, if we find an optional one, we do the same report call but with the optional attribute changed to let's say string_attr-val-2.
Then the expected value should be 1+<number of optional attributes>
|
@shalper2 Is there any reason for the Disabling an attribute globally might lead to a user having to define multiple instances of a receiver if aggregation is needed just for a metric. For example, one might be interested in aggregating only in cpu states for utilization metrics: scrapers:
cpu:
metrics:
system.cpu.time: <- No aggregation, using default attributes definition attributes: [cpu, state]
enabled: true
system.cpu.utilization:
enabled: true
attributes: [cpu] <- Override default attributesThe previous configuration looks more aligned with the actual system.cpu.time:
enabled: true
description: ""
unit: s
sum:
value_type: double
aggregation_temporality: cumulative
monotonic: true
attributes: [cpu, state]
system.cpu.utilization:
enabled: false
description: ""
unit: "1"
gauge:
value_type: double
attributes: [cpu, state]Any thoughts on this? |
|
hey @rogercoll! The root level approach was considered mainly due to this thread. I think what you're proposing makes sense! I also think that having a set of attributes disabled at the root of the receiver is pretty clear and, while more verbose, easier to use in existing |
Thanks for sharing this. If I understand open-telemetry/opentelemetry-collector-contrib#16533 correctly, the idea was to move the attributes into the metric section. Attributes are only valuable when used/referenced by metrics. Although enabling/disabling an attribute at the root level for all metrics might be valuable in some cases, I personally think that using the metrics attributes reference to configure the set of attributes for that metric will be more flexible and non-breaking. We won't need to add the @shalper2 Do you think my suggestion would be feasible? Does it make the code generation process more complex? |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
Closed as inactive. Feel free to reopen if this PR is still being worked on. |
Please note this is still very much a work in progress.
Description
Modified
mdatagento allow for two new fields in the configuration yaml of metrics. These new configuration options would allow for a user to enable or disable attributes (i.e. reduce dimensionality of metrics being generated) from their collector configuration. The modifiedMetricsBuildergenerated bymdatagenautomatically re-aggregates metrics based on the enabled set of attributes. Additionally, different aggregation strategies can be specified by the collector administrator.The changes to the config.yaml are:
Note that this will not change metadata.yaml so users can expect the same overall
mdatagenexperience. Default values for the modifiedMetricsBuilderare to enable all attributes included inmdatagen.Link to tracking issue
Fixes 10726
Testing
Some testing has been done using the modified mdatagen with existing contrib receivers (i.e.
hostmetricsreceiver)Documentation