Repository navigation
Add fluent metric point assertions - #8994
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pull request dashboard statusMerged · refreshed 2026-11-03 22:03 UTC Status above doesn't look right?
|
|
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the new fluent metric assertion shortcuts.
No open issues 🎉
What changed in this PR
Adds fluent, typed point assertions directly to MetricAssert, reducing nested callbacks while preserving existing type-level assertions and matching behavior.
Changes:
- Adds varargs and iterable shortcuts for all seven metric types, returning
MetricAssertfor continued chaining. - Tests chaining, any-order and exact matching, mismatched points, and null and wrong-type failures.
- Updates the API compatibility report with the new overloads.
| File | Description |
|---|---|
| sdk/testing/src/test/java/io/opentelemetry/sdk/testing/assertj/MetricAssertionsTest.java | Tests the shortcuts and their success and failure behavior. |
| sdk/testing/src/main/java/io/opentelemetry/sdk/testing/assertj/MetricAssert.java | Adds 14 fluent overloads delegating to existing typed assertions. |
| docs/apidiffs/current_vs_latest/opentelemetry-sdk-testing.txt | Records the new public assertion methods. |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8994 +/- ##
============================================
+ Coverage 90.36% 90.38% +0.02%
- Complexity 10995 11012 +17
============================================
Files 1020 1020
Lines 30096 30112 +16
Branches 3929 3929
============================================
+ Hits 27197 27218 +21
+ Misses 1942 1937 -5
Partials 957 957 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jack-berg
left a comment
There was a problem hiding this comment.
Looks good to me. Tried out the new APIs locally on some metric tests and the assertions become flatter and more readable.
Add fluent typed-point assertions to
MetricAssert. For the common Java instrumentation pattern below, removing the intermediate histogram callback saves eight spaces of indentation throughout the point assertions.Before:
After:
The shortcuts cover all seven metric types, accept varargs or iterable point assertions, and return
MetricAssertfor continued chaining.