Skip to content

Comments

fix: Handle empty datapoints in otel exporter#1898

Merged
zeitlinger merged 3 commits intomainfrom
exclude-empty-datapoint
Feb 20, 2026
Merged

fix: Handle empty datapoints in otel exporter#1898
zeitlinger merged 3 commits intomainfrom
exclude-empty-datapoint

Conversation

@jaydeluca
Copy link
Collaborator

@jaydeluca jaydeluca commented Feb 19, 2026

From @dhoard on slack, There was an error in the jmx-exporter project smoke tests:

time=2026-02-16T15:49:03.466Z level=ERROR source=write_handler.go:652 msg="Error appending remote write" component=web err="empty data points. jvm_memory_pool_allocated_bytes is dropped"
2026-02-16 15:49:03.482 | OkHttp http://prometheus:9090/... | WARNING | e1723a08afd7bca35570fd31a7656f59.io.prometheus.metrics.shaded.io_opentelemetry_2_25_0_alpha.exporter.internal.http.HttpExporter | Failed to export metrics. Server responded with HTTP status code 500. Error message: Unable to parse response body, HTTP status message: Internal Server Error

Looking at the documentation for jvm_memory_pool_allocated_bytes... "Only updated after GC, not continuously." Most likely GC hasn't happened, yet the OTel exporter is trying to write the data.

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.

Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
@jaydeluca jaydeluca changed the title Handle empty datapoints in otel exporter fix: Handle empty datapoints in otel exporter Feb 19, 2026
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
@jaydeluca jaydeluca marked this pull request as ready for review February 19, 2026 16:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 return null when 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.

This comment was marked as outdated.

Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
Copy link
Member

@zeitlinger zeitlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!

@zeitlinger zeitlinger merged commit 59c8552 into main Feb 20, 2026
15 of 16 checks passed
@zeitlinger zeitlinger deleted the exclude-empty-datapoint branch February 20, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants