[Metrics SDK] Fix spatial re-aggregation for asynchronous instruments - #4635
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4635 +/- ##
==========================================
+ Coverage 86.66% 86.70% +0.05%
==========================================
Files 525 525
Lines 20481 20596 +115
==========================================
+ Hits 17748 17856 +108
- Misses 2733 2740 +7
🚀 New features to boost your workflow:
|
|
@nikhilbhatia08 - Thanks for working on this. The review uncovered some issues in the existing async storage design that make this broader than the original fix. Could you hold off on further implementation while I work through the design? Your PR is a useful starting point, and we can split the implementation once the approach is clear. |
|
Yeah Sure @lalitb, that works, Thanks! |
|
@nikhilbhatia08 - Could we calculate deltas before removing attributes for monotonic Sum aggregation? Suppose the view removes the attribute named Removing Could we:
The existing With the existing cumulative reconstruction, this example produces Non-monotonic sums, such as UpDownCounters, need different handling. If two processes use 100 and 50 units of memory, and the second process exits, the current total should become 100. Could we sum their filtered absolute observations across all callbacks first, then calculate the difference once in Please add tests for the two-callback case, the disappearing counter, and the UpDownCounter example. For output overflow, check that contributions combine correctly in the first collection, including in the If a filtered group disappears entirely, #4484 is addressing that stale-output behavior through #4108. Please keep this change compatible with its baseline-preservation and stale-suppression handling. |
|
@nikhilbhatia08 - Thanks, the change look good. can you fix the CI so it is in good state? |
- Add the includes include-what-you-use asks for in async_metric_storage_test.cc (<map>, attribute_utils.h, aggregation_config.h) and use <cstddef> instead of the deprecated <stddef.h>, matching the rest of sdk/test/metrics. - Drop noexcept from the new private helpers (RecordMonotonicSum, AccumulateDelta, FilterAttributes). They allocate and can throw; the noexcept boundary stays on the public Record/Collect entry points, so behaviour is unchanged and bugprone-exception-escape no longer fires on them.
7087038 to
74c21dd
Compare
|
Hey @lalitb fixed the ci, its green now, thanks! |
Fixes #1724
Changes
Fix spatial re-aggregation for asynchronous instruments. A view which drops attributes is now applied to asynchronous instruments as well, and the observations which collapse onto the same attribute set are re-aggregated (summed up for the additive instruments) instead of the last observation overwriting the previous ones. Note that
AsyncMetricStorage's constructor now takes the view'sAttributesProcessor, matchingSyncMetricStorage.For significant contributions please make sure you have completed the following items:
CHANGELOG.mdupdated for non-trivial changes