[METRICS] Drop stale async attribute sets from cumulative exports#4140
Open
pranitaurlam wants to merge 2 commits into
Open
[METRICS] Drop stale async attribute sets from cumulative exports#4140pranitaurlam wants to merge 2 commits into
pranitaurlam wants to merge 2 commits into
Conversation
Author
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4140 +/- ##
==========================================
+ Coverage 82.01% 82.03% +0.03%
==========================================
Files 385 385
Lines 16093 16103 +10
==========================================
+ Hits 13197 13209 +12
+ Misses 2896 2894 -2
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4108
Summary
The OpenTelemetry SDK spec states:
Bug: Under cumulative temporality, async instruments (
ObservableCounter,ObservableGauge,ObservableUpDownCounter) kept emitting attribute sets indefinitely after the callback stopped reporting them. The frozen values would appear in every subsequent export with the stale last-observed value (and forObservableGauge, even with a frozen timestamp).Root cause in
TemporalMetricStorage::buildMetrics(): the cumulative merge unconditionally carried every entry fromlast_reported_metrics_into the output even if it was absent from the current delta.Changes (3 files)
temporal_metric_storage.h/.ccis_async_boolean (defaultfalse) toTemporalMetricStorageelse if (!is_async_)guard: sync instruments still carry forward all attribute sets (existing behaviour, spec-correct); async instruments skip stale entries not present in the current deltaasync_metric_storage.his_async = truewhen constructingTemporalMetricStorageCollect(), rebuildcumulative_hash_map_to contain only entries present indelta_metrics— prevents unbounded memory growth and ensures correct delta computation if an attribute set reappears after a gapBehaviour
Sister SDKs: opentelemetry-dotnet #6883 and opentelemetry-rust #2618 have shipped equivalent fixes.
cc @marcalff @lalitb @ThomsonTan @kyusic