Repository navigation
Conversation
Pull request dashboard statusWaiting on the author · refreshed 2026-10-21 02:35 UTC Move out of draft to request review. Status above doesn't look right?
|
Co-authored-by: trask <218610+trask@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add test utilities for better coverage
Add normalized metric assertion utilities
Oct 21, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Normalization can reject valid histograms, discard independent snapshots, and merge distinct metric identities.
3 open issues
What changed in this PR
Adds normalized metric assertions to shared testing infrastructure across library, agent, and smoke-test runners.
Changes:
- Aggregates DELTA metrics and selects latest snapshot data.
- Adds typed helpers and exhaustive metric-identity matching.
- Updates shared assertions and adds normalization tests.
| File | Description |
|---|---|
| testing-common/src/test/java/io/opentelemetry/instrumentation/testing/util/MetricAssertionsTest.java | Tests typed assertion helpers. |
| testing-common/src/test/java/io/opentelemetry/instrumentation/testing/junit/MetricCollectionTest.java | Tests library collection behavior. |
| testing-common/src/test/java/io/opentelemetry/instrumentation/testing/internal/MetricDataAggregatorTest.java | Tests aggregation and snapshot selection. |
| testing-common/src/test/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunnerMetricsTest.java | Tests exhaustive identity matching. |
| testing-common/src/main/java/io/opentelemetry/javaagent/testing/common/AgentTestingExporterAccess.java | Exposes separate agent metric collections. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/util/MetricAssertions.java | Adds typed metric assertions. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/LibraryTestRunner.java | Captures library collection boundaries. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/MessagingMetricsAssertions.java | Adopts normalized messaging assertions. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/InstrumentationExtension.java | Exposes exhaustive metric assertions. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java | Uses the histogram helper. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java | Uses the histogram helper. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbConnectionPoolMetricsAssertions.java | Adopts typed pool metric assertions. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/DbClientMetricsTestUtil.java | Adopts the histogram helper. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/internal/MetricDataAggregator.java | Implements metric normalization. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/internal/CollectionCapturingMetricExporter.java | Stores exports as separate collections. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/InstrumentationTestRunner.java | Normalizes metrics before assertions. |
| testing-common/src/main/java/io/opentelemetry/instrumentation/testing/AgentTestRunner.java | Exposes agent collections. |
| testing-common/integration-tests/src/test/java/instrumentation/MetricCollectionTest.java | Tests agent collection behavior. |
| smoke-tests/src/main/java/io/opentelemetry/smoketest/TelemetryRetriever.java | Preserves metric request boundaries. |
| smoke-tests/src/main/java/io/opentelemetry/smoketest/SmokeTestRunner.java | Exposes retrieved collections. |
| smoke-tests-otel-starter/spring-smoke-testing/src/main/java/io/opentelemetry/spring/smoketest/SpringSmokeTestRunner.java | Captures starter metric collections. |
Review effort: Balanced
Comment on lines
+52
to
+54
| metrics | ||
| .computeIfAbsent(new MetricIdentity(metric), unused -> new ArrayList<>()) | ||
| .add(new MetricSnapshot(collectionIndex, metric)); |
Comment on lines
+514
to
+515
| ExponentialHistogramBuckets positive = buckets(positiveBuckets); | ||
| ExponentialHistogramBuckets negative = buckets(negativeBuckets); |
Comment on lines
+100
to
+101
| private static boolean isLatestSnapshot(List<MetricSnapshot> snapshots, int latestCollection) { | ||
| return snapshots.get(snapshots.size() - 1).collectionIndex == latestCollection; |
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.


Normalize captured metric collections before shared assertions: aggregate DELTA sums and histograms, and use the latest snapshot for gauges, summaries, and cumulative data. Preserve metric identity and collection boundaries across library, agent, and smoke-test runners.