-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[mdatagen] Re-Aggregate Metric by Attributes #13431
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
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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General approach sounds good
cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_config.go
Outdated
Show resolved
Hide resolved
64e3dfc
to
b8282b3
Compare
cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_metrics.go
Outdated
Show resolved
Hide resolved
cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_metrics.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good to me, thanks for working on this 🚀
da870bc
to
ca1d369
Compare
cmd/mdatagen/internal/sampleconnector/internal/metadata/generated_config.go
Outdated
Show resolved
Hide resolved
9a15932
to
09f9aff
Compare
cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_metrics_test.go
Outdated
Show resolved
Hide resolved
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is redundant
|
||
defaultMetricsCount++ | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 attributes The 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
mdatagen
to 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 modifiedMetricsBuilder
generated bymdatagen
automatically 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
mdatagen
experience. Default values for the modifiedMetricsBuilder
are 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