Skip to content

Add containsPointsSatisfying to metric data asserts#8329

Merged
jack-berg merged 2 commits intoopen-telemetry:mainfrom
trask:contains-points-satisfying
Apr 28, 2026
Merged

Add containsPointsSatisfying to metric data asserts#8329
jack-berg merged 2 commits intoopen-telemetry:mainfrom
trask:contains-points-satisfying

Conversation

@trask
Copy link
Copy Markdown
Member

@trask trask commented Apr 24, 2026

Unfortunately, we can't follow hasAttributesSatisfying / hasAttributesSatisfyingExactly pattern, since hasPointsSatisfying is doing the "Exactly" behavior already.

containsPointsSatisfying is the best name I could come up with to differentiate with hasPointsSatisfying.

Demonstration of this new method at open-telemetry/opentelemetry-java-instrumentation#18263

Parallels hasAttributesSatisfying's subset semantics: each listed
assertion must be satisfied by at least one point, extras are allowed,
and a single point may satisfy multiple assertions.

The existing hasPointsSatisfying requires the caller to enumerate every
point (via satisfiesExactlyInAnyOrder), which is awkward when point
cardinality varies across runs (e.g. JVM runtime telemetry snapshots).
Today callers drop down to raw AssertJ:

  sum.satisfies(s -> assertThat(s.getPoints())
      .anyMatch(p -> p.getAttributes().equals(...))
      .anyMatch(p -> p.getAttributes().equals(...)))

which is noisy and loses the typed PointAssert. containsPointsSatisfying
keeps the typed chain.

Added to: DoubleGaugeAssert, DoubleSumAssert, LongGaugeAssert,
LongSumAssert, HistogramAssert, ExponentialHistogramAssert,
SummaryAssert.
@otelbot otelbot Bot added the api-change Changes to public API surface area label Apr 24, 2026
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Apr 24, 2026

⚠️ API changes detected — additional maintainer review required

@jack-berg @jkwatson

This PR modifies the public API surface area of the following module(s):

  • opentelemetry-sdk-testing

Please review the changes in docs/apidiffs/current_vs_latest/ carefully before approving.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.28%. Comparing base (f674cdd) to head (6d2f014).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8329      +/-   ##
============================================
+ Coverage     90.27%   90.28%   +0.01%     
- Complexity     7695     7722      +27     
============================================
  Files           850      850              
  Lines         23213    23262      +49     
  Branches       2356     2363       +7     
============================================
+ Hits          20955    21003      +48     
  Misses         1531     1531              
- Partials        727      728       +1     

☔ 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.

@trask trask marked this pull request as ready for review April 24, 2026 17:20
@trask trask requested a review from a team as a code owner April 24, 2026 17:20
@jack-berg
Copy link
Copy Markdown
Member

Will merge when conflicts are resolved @trask

…isfying

# Conflicts:
#	CHANGELOG.md
#	docs/apidiffs/current_vs_latest/opentelemetry-sdk-testing.txt
@jack-berg jack-berg merged commit 2fe0a14 into open-telemetry:main Apr 28, 2026
45 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-change Changes to public API surface area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants