Skip to content

[TEST] Fix flaky gauge delta multi-reader tests on coarse clocks - #4805

Merged
marcalff merged 2 commits into
open-telemetry:mainfrom
dbarker:fix-flaky-gauge-multireader-test
Nov 23, 2026
Merged

marcalff merged 2 commits into
open-telemetry:mainfrom
dbarker:fix-flaky-gauge-multireader-test

Conversation

@dbarker

@dbarker dbarker commented Nov 23, 2026

Copy link
Copy Markdown
Member

Fixes # (issue)
The WritableMetricStorageDeltaMultiReaderTestFixture.LongGaugeLastValueAggregationDeltaTemporalityMultiReader test is flaky in CI due to a time based check.

[----------] 1 test from WritableMetricStorageTestLongDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture
[ RUN      ] WritableMetricStorageTestLongDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture.LongGaugeLastValueAggregationDeltaTemporalityMultiReader/0
[       OK ] WritableMetricStorageTestLongDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture.LongGaugeLastValueAggregationDeltaTemporalityMultiReader/0 (0 ms)
[----------] 1 test from WritableMetricStorageTestLongDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture (0 ms total)

[----------] 1 test from WritableMetricStorageTestDoubleDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture
[ RUN      ] WritableMetricStorageTestDoubleDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture.LongGaugeLastValueAggregationDeltaTemporalityMultiReader/0
/Users/runner/work/opentelemetry-cpp/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_gauge_test.cc:291: Failure
Expected: (metric_a_cycle1.start_ts.time_since_epoch()) > (sdk_start_ts.time_since_epoch()), actual: 8-byte object <80-DA 8C-9E CF-83 EA-18> vs 8-byte object <90-B9 03-5A E6-60 06-00>

/Users/runner/work/opentelemetry-cpp/opentelemetry-cpp/sdk/test/metrics/sync_metric_storage_gauge_test.cc:380: Failure
Expected: (metric_b_cycle1.start_ts.time_since_epoch()) > (sdk_start_ts.time_since_epoch()), actual: 8-byte object <80-DA 8C-9E CF-83 EA-18> vs 8-byte object <90-B9 03-5A E6-60 06-00>

[  FAILED  ] WritableMetricStorageTestDoubleDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture.LongGaugeLastValueAggregationDeltaTemporalityMultiReader/0, where GetParam() = 1-byte object <01> (0 ms)
[----------] 1 test from WritableMetricStorageTestDoubleDeltaMultiReader/WritableMetricStorageDeltaMultiReaderTestFixture (0 ms total)

Changes

On macOS the system clock only counts whole microseconds, so sdk_start_ts and the instrument creation time could get the same value and fail the strict EXPECT_GT. Setting sdk_start_ts to 60s before before_creation (as the counter tests already do) makes the check reliable.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@dbarker
dbarker marked this pull request as ready for review November 23, 2026 01:30
@dbarker
dbarker requested a review from a team as a code owner November 23, 2026 01:30
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.69%. Comparing base (e4f33b6) to head (02f80bb).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4805      +/-   ##
==========================================
- Coverage   86.70%   86.69%   -0.00%     
==========================================
  Files         530      530              
  Lines       21206    21206              
==========================================
- Hits        18384    18382       -2     
- Misses       2822     2824       +2     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbarker dbarker added issue:blocking This issue is preventing other fixes pr:please-review This PR is ready for review labels Nov 23, 2026
@shashankxrm shashankxrm mentioned this pull request Nov 23, 2026
3 tasks done

@mateenali66 mateenali66 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix.

All six EXPECT_GT checks against sdk_start_ts in sdk/test now use the 60 s offset.

The double variant failed the same way on #4795, both timestamps equal to the microsecond.

@marcalff
marcalff merged commit 90802ae into open-telemetry:main Nov 23, 2026
102 checks passed
@marcalff marcalff changed the title [TEST] Fix flaky gauge delta multi-reader tests on macos [TEST] Fix flaky gauge delta multi-reader tests on coarse clocks Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

issue:blocking This issue is preventing other fixes pr:please-review This PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants