Skip to content

Conversation

@jack-berg
Copy link
Member

I'm doing some work to improve the performance of metric recording under high contention, and touching sensitive code in DefaultSynchronousMetricStorage and other concurrent code.

I have promising results, but the first step is buffing up our stress tests for synchronous instruments.

A stress test for synchronous instruments concurrently runs record and collect operations at a high rate, and tries to find instances of concurrency bugs: lost writes, duplicate writes, partial writes, etc.

We need to test every combination of of the following dimensions, since each plays a key role in the recording and collecting code flows.

  • instrument type (counter, up down counter, explicit histogram, expo histogram, gauge) = 5
  • instrument value type (double, long) = 2
  • memory mode (reusuable, immutable) = 2
  • aggregation temporality (cumulative, delta) = 2

That's 40 combinations. Our current test suite is hand rolled for some of these cases, but misses many.

AggregationTemporality aggregationTemporality,
InstrumentType instrumentType,
MemoryMode memoryMode,
InstrumentValueType instrumentValueType) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Parameterized testing really shines here.

Uninterruptibles.joinUninterruptibly(collectThread);

// Assert collected data is consistent with recorded measurements by independently computing the
// expected aggregated value and comparing to the actual results.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the key bit. We independently compute the expected aggregated state outside the concurrent record environment, and compare against the SDK, treating it as a black box.

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.16%. Comparing base (d6ad3ae) to head (03670f6).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7986      +/-   ##
============================================
- Coverage     90.16%   90.16%   -0.01%     
+ Complexity     7478     7473       -5     
============================================
  Files           836      833       -3     
  Lines         22550    22524      -26     
  Branches       2224     2235      +11     
============================================
- Hits          20333    20308      -25     
+ Misses         1515     1512       -3     
- Partials        702      704       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@jack-berg jack-berg marked this pull request as ready for review January 19, 2026 17:18
@jack-berg jack-berg requested a review from a team as a code owner January 19, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant