fix: Handle empty datapoints in otel exporter#1898
Merged
zeitlinger merged 3 commits intomainfrom Feb 20, 2026
Merged
Conversation
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where the OpenTelemetry exporter was attempting to export metrics with empty data points, causing server errors. The fix addresses a scenario where metrics like jvm_memory_pool_allocated_bytes are registered with label names but have no data points until after garbage collection occurs.
Changes:
- Added empty data point checks to all
MetricDataFactory.create()methods to returnnullwhen no data points exist - Made the test extension field static to properly share the OpenTelemetryExtension across tests
- Added comprehensive test case to verify metrics without data points are not exported
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| MetricDataFactory.java | Added @Nullable annotations and empty data point checks to all create methods (Counter, Gauge, Summary, Info, StateSet, Unknown) |
| ExportTest.java | Made OpenTelemetryExtension static and added test for metrics without data points |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ter-opentelemetry/src/test/java/io/prometheus/metrics/exporter/opentelemetry/ExportTest.java
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
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.
From @dhoard on slack, There was an error in the jmx-exporter project smoke tests:
I updated the method to return null when the data points are empty, which is then handled via the addUnlessNull method.
After applying this change locally, I ran the quick test a few times and the error was no longer present.