server: Implement unwrap server transport stream#9108
Draft
hugehoo wants to merge 5 commits intogrpc:masterfrom
Draft
server: Implement unwrap server transport stream#9108hugehoo wants to merge 5 commits intogrpc:masterfrom
hugehoo wants to merge 5 commits intogrpc:masterfrom
Conversation
…ortStream SetSendCompressor and ClientSupportedCompressors fail when the ServerTransportStream in context is wrapped (e.g. by OpenTelemetry's attachLabelsTransportStream), because they directly type-assert to *transport.ServerStream. Add an unwrapServerTransportStream helper that traverses wrapper layers using the Unwrap() pattern (similar to errors.Unwrap) to find the underlying *transport.ServerStream. A visited-set guards against infinite loops from buggy Unwrap implementations. Update both SetSendCompressor and ClientSupportedCompressors to use this helper instead of direct type assertions. Fixes grpc#9047
Add Unwrap() to attachLabelsTransportStream so that unwrapServerTransportStream can traverse through it to find the underlying *transport.ServerStream. This fixes SetSendCompressor and ClientSupportedCompressors when the OpenTelemetry stats plugin is active.
Add unit tests for the unwrapServerTransportStream helper covering direct, single-wrapped, nested-wrapped, non-unwrappable, and nil cases. Add a cycle protection test verifying that a self-referencing Unwrap terminates instead of looping infinitely. Add regression tests for SetSendCompressor and ClientSupportedCompressors with a wrapped context, directly exercising the scenario from grpc#9047.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9108 +/- ##
==========================================
- Coverage 83.12% 83.05% -0.07%
==========================================
Files 413 413
Lines 33484 33497 +13
==========================================
- Hits 27832 27821 -11
- Misses 4229 4246 +17
- Partials 1423 1430 +7
🚀 New features to boost your workflow:
|
Fix vet.sh failure by wrapping bare context.Background() with context.WithTimeout. Also align with codebase conventions: reorder helper types, rename tt to test, and simplify error messages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove extra spacing in mockServerTransportStream method alignment to satisfy goimports formatting check in vet.sh. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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.
fixes #9047
changes
server.go: Add
unwrapServerTransportStreamhelper that traverseswrapper layers using the
Unwrap()pattern.Unwrapimplementations. UpdateSetSendCompressorandClientSupportedCompressorsto use this helper instead of direct type assertions.stats/opentelemetry/server_metrics.go: Add
Unwrap()method to so the helper can reach the underlying*transport.ServerStream.server_test.go: Add unit tests for the unwrap helper, cycle protection test, and regression tests for
SetSendCompressor/ClientSupportedCompressorswith a wrapped context.RELEASE NOTES: N/A