Skip to content

Avoid serializing exceptions as JSON in OTLP endpoint#144045

Merged
felixbarny merged 4 commits intoelastic:mainfrom
felixbarny:otlp-action-listener
Mar 19, 2026
Merged

Avoid serializing exceptions as JSON in OTLP endpoint#144045
felixbarny merged 4 commits intoelastic:mainfrom
felixbarny:otlp-action-listener

Conversation

@felixbarny
Copy link
Copy Markdown
Member

@felixbarny felixbarny commented Mar 11, 2026

Avoid using a RestResponseListener in AbstractOTLPRestAction so that the response is never rendered as JSON, even for exceptions that get thrown before the transport action is invoked.

The transport action now uses the onFailure callback instead of onResponse for error cases, which simplifies the handling and makes it more idiomatic. Error cases (all data points ignored, 429 throttling, processing exceptions) go through onFailure, while success and partial success (HTTP 200 per the OTLP spec) continue to use onResponse.

Failure responses now use a Protobuf-encoded google.rpc.Status message as required by the OTLP spec:

The response body for all HTTP 4xx and HTTP 5xx responses MUST be a Protobuf-encoded Status message that describes the problem.

Previously, we were using a ExportMetricsPartialSuccess message which is not spec compliant.

This mirrors the changes made for Prometheus in #143987.

Depends on #144009.

@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team v9.4.0 labels Mar 11, 2026
@felixbarny felixbarny self-assigned this Mar 11, 2026
@felixbarny felixbarny force-pushed the otlp-action-listener branch from 78a9e5a to 19c7c89 Compare March 13, 2026 15:43
@felixbarny felixbarny marked this pull request as ready for review March 13, 2026 17:22
@felixbarny felixbarny requested a review from a team as a code owner March 13, 2026 17:22
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Mar 13, 2026
…lure responses

Guard against null exception messages in sendFailureResponse, and add a comment
explaining that Status.code is intentionally omitted per the OTLP spec, which
states the server MAY omit it and clients must not alter behavior based on it.
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Mar 13, 2026
Copy link
Copy Markdown
Contributor

@sidosera sidosera left a comment

Choose a reason for hiding this comment

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

LGTM!

Co-authored-by: Sergey Sidorov <SERGEY.IVANOVICH.SIDOROV@gmail.com>
@felixbarny felixbarny enabled auto-merge (squash) March 19, 2026 06:50
@felixbarny felixbarny merged commit 586b972 into elastic:main Mar 19, 2026
36 checks passed
michalborek pushed a commit to michalborek/elasticsearch that referenced this pull request Mar 23, 2026
Co-authored-by: Sergey Sidorov <SERGEY.IVANOVICH.SIDOROV@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :StorageEngine/TSDB You know, for Metrics Team:StorageEngine v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants