[METRICS] Enable synchronous gauge delta temporality and add tests for multi reader path#4159
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4159 +/- ##
==========================================
+ Coverage 82.82% 82.86% +0.04%
==========================================
Files 406 406
Lines 16913 16912 -1
==========================================
+ Hits 14007 14012 +5
+ Misses 2906 2900 -6
🚀 New features to boost your workflow:
|
lalitb
left a comment
There was a problem hiding this comment.
LGTM, with nit comment. Also the PR title should be updated because this PR is not only adding tests. It also enables sync gauge delta temporality by removing the fallback to cumulative.
|
Hi, @marcalff @ThomsonTan When you have a moment, could you please review this PR? |
Thank you for your review. Do you know if this change could make it into the next release cycle? |
Fixes #4146
Changes
Delta temporality for synchronous gauge instruments was previously unsupported and silently fell back to cumulative. This PR removes that restriction and verifies correct behaviour on the multi-reader slow path (
unreported_metrics_).metric_collector.ccRemoved the guard that rejected
kDeltaforInstrumentType::kGaugeand force-overrode it tokCumulative. Delta temporality for synchronous gauge is now fully supported.temporal_metric_storage.ccClarified the fast-path comment: it applies to all instrument types (not just counter/updown-counter/histogram), and documents the window-scoped last-value semantics for synchronous gauge — only values recorded since the previous collection are emitted; stale values are not re-exported.
sync_metric_storage_gauge_test.ccWritableMetricStorageDeltaMultiReaderTestFixture, a dedicated fixture for multi-reader delta tests (prevents cross-instantiation with the existing cumulative fixture).LongGaugeLastValueAggregationDeltaTemporalityMultiReader(parameterized, int64_t).DoubleGaugeLastValueAggregationDeltaTemporalityMultiReader(parameterized, double).Both new tests exercise the slow path (
collectors.size() > 1) and verify:start_tsequals instrument creation time (spec [Delta temporality uses MeterProvider start time instead of per-instrument creation time for first collection interval #4062]).start_tsadvances to the previousend_ts.record→collect→no record→collect) do not invoke the callback — stale gauge values are not re-emitted, for bothcollector_aandcollector_bindependently.collector_b) receives the merged last-value from all prior intervals withstart_ts= instrument creation time.