Skip to content

Read the gRPC status of responses compressed with the request's encoding - #9058

Open
kerolloz wants to merge 1 commit into
open-telemetry:mainfrom
kerolloz:okhttp-grpc-response-in-request-encoding
Open

kerolloz wants to merge 1 commit into
open-telemetry:mainfrom
kerolloz:okhttp-grpc-response-in-request-encoding

Conversation

@kerolloz

@kerolloz kerolloz commented Nov 24, 2026 •

Copy link
Copy Markdown

Fixes #9057

grpc-go servers (such as the Collector) compress the response with the request's encoding. With a non-gzip Compressor like zstd, OkHttpGrpcSender couldn't decompress it and failed every export with INTERNAL, although the data was accepted.

A response in the request's own encoding now resolves from grpc-status and skips the body, which only carries partial success. Other encodings are still rejected.

  • Tests: success and error-status cases for OkHttpGrpcSender. doubleShutdown no longer assumes no earlier test logged anything.
  • End to end (agent 2.33.1 + zstd, gRPC to collector-contrib 0.151.0): spans reported as failed went from 100% to 0.

grpc-go servers, such as the OpenTelemetry Collector, compress the
response with the request's encoding. With a Compressor other than gzip
(for example zstd), OkHttpGrpcSender failed every export with INTERNAL
"Unsupported gRPC message encoding", although the server accepted the
data and responded with grpc-status 0.

A response compressed with the request's own encoding now resolves from
its grpc-status and grpc-message. Compressor can't decompress, so the
body, which only carries partial success, is skipped. Other encodings
are still rejected with INTERNAL.

doubleShutdown now checks the first shutdown doesn't log "Calling
shutdown() multiple times." instead of that nothing was logged: the
captured events can include those of the test that ran before it.
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-25 22:49 UTC

Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):

  • Top-level threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@kerolloz
kerolloz marked this pull request as ready for review November 24, 2026 14:04
@kerolloz
kerolloz requested a review from a team as a code owner November 24, 2026 14:04
@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.56%. Comparing base (a91844f) to head (b3b722a).

Files with missing lines Patch % Lines
...orter/sender/okhttp/internal/OkHttpGrpcSender.java 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9058      +/-   ##
============================================
- Coverage     90.56%   90.56%   -0.01%     
- Complexity    11197    11198       +1     
============================================
  Files          1032     1032              
  Lines         30524    30532       +8     
  Branches       3999     4000       +1     
============================================
+ Hits          27644    27650       +6     
  Misses         1909     1909              
- Partials        971      973       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jack-berg jack-berg left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for investigating this and providing the reproduction. There are two separate issues here: the server's response encoding and our support for decoding custom encodings.

The Collector appears noncompliant in this case. The client advertises grpc-accept-encoding: identity,gzip, but receives a zstd-compressed response. Using zstd to compress the request does not advertise support for decompressing zstd responses. The gRPC compression specification says the server SHALL send the message uncompressed when the requested response compression is unsupported by the client. It also specifies INTERNAL on the client when the server sends an unsupported encoding. Although the telemetry was received, INTERNAL is arguably the correct characterization of this noncompliant response. This appears to originate in grpc-go's default response-compressor selection and warrants an upstream report.

On the Java side, I think silently discarding the response body when its encoding matches the request is too narrow a workaround. GrpcSender is a generic transport whose response contract includes the decompressed message, even though the OTLP exporter currently ignores that message.

I'd prefer to address custom response compression generally:

  1. Introduce a decompressor concept, with a compatible evolution path for the existing compression SPI.
  2. Decode response bodies using registered decompressors, and advertise the encodings we can actually decode. The contrib zstd implementation would need to provide decompression support too.
  3. Support UpstreamGrpcSender by integrating those decompressors with grpc-java's DecompressorRegistry, including an explicit approach for user-supplied channels. The sender-specific test assumptions currently leave this path unresolved.
  4. Support the HTTP senders as well. Both currently reject response encodings other than gzip and identity. This is the same capability gap, although it does not establish that the Collector's HTTP receiver exhibits the same negotiation problem.

This type of approach doesn't have to be done by you and definitely not all in one PR.

This branch has not been deployed

No deployments
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.

OTLP gRPC exports with a SPI compressor (e.g. zstd) fail when the server responds in the same encoding

2 participants