Use containsPointsSatisfying in metric assertions#18263
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates metric assertion style in tests to use the newer OpenTelemetry AssertJ convenience APIs (notably hasLongSumSatisfying(...) and containsPointsSatisfying(...)) introduced upstream, simplifying point matching and removing direct MetricData point iteration.
Changes:
- Refactor runtime-telemetry memory metric tests to assert long-sum data via
hasLongSumSatisfying(...)and validate expected points viacontainsPointsSatisfying(...). - Simplify metaspace/code-cache metric tests by replacing manual
anyMatch(...)checks with point-level assertion lambdas. - Update a Pulsar metric test to use
containsPointsSatisfying(...)for matching a specificmessaging.receive.messagespoint.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| instrumentation/runtime-telemetry/library/src/testJava17/java/io/opentelemetry/instrumentation/runtimetelemetry/PsGcMemoryMetricTest.java | Switch memory metric assertions to hasLongSumSatisfying and point-based checks via containsPointsSatisfying. |
| instrumentation/runtime-telemetry/library/src/testJava17/java/io/opentelemetry/instrumentation/runtimetelemetry/MetaspaceMemoryUsageMetricTest.java | Replace manual point iteration with hasLongSumSatisfying + containsPointsSatisfying. |
| instrumentation/runtime-telemetry/library/src/testJava17/java/io/opentelemetry/instrumentation/runtimetelemetry/MetaspaceMemoryLimitMetricTest.java | Replace manual point iteration with hasLongSumSatisfying + containsPointsSatisfying. |
| instrumentation/runtime-telemetry/library/src/testJava17/java/io/opentelemetry/instrumentation/runtimetelemetry/MetaspaceMemoryCommittedMetricTest.java | Replace manual point iteration with hasLongSumSatisfying + containsPointsSatisfying. |
| instrumentation/runtime-telemetry/library/src/testJava17/java/io/opentelemetry/instrumentation/runtimetelemetry/G1GcMemoryMetricTest.java | Use hasLongSumSatisfying and containsPointsSatisfying for expected pool points. |
| instrumentation/runtime-telemetry/library/src/testJava17/java/io/opentelemetry/instrumentation/runtimetelemetry/CodeCacheMemoryInitMetricTest.java | Convert value/attribute anyMatch into point-level assertions using containsPointsSatisfying. |
| instrumentation/pulsar/pulsar-2.8/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/pulsar/v2_8/PulsarClientTest.java | Update a messaging.receive.messages assertion to use containsPointsSatisfying for matching the batch receive count point. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
laurit
approved these changes
May 11, 2026
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.
Using convenience API introduced in open-telemetry/opentelemetry-java#8329