Skip to content

Standardize UpstreamGrpcSender shutdown to await channel termination#8624

Draft
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/standardize-upstream-grpc-sender-shutdown
Draft

Standardize UpstreamGrpcSender shutdown to await channel termination#8624
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/standardize-upstream-grpc-sender-shutdown

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Related to #8280

Description

  • shutdown() called channel.shutdownNow() and returned ofSuccess() right away, signalling completion before the channel had terminated.
  • It now awaits termination for up to 5 seconds on a daemon thread, logs a warning on timeout, and succeeds either way — mirroring OkHttpHttpSender, standardized in Standardize OkHttpHttpSender shutdown to await executor termination #8495.
  • Only the fallback channel we create is shut down; a caller-supplied channel is untouched and still returns immediately.
  • The okhttp senders also run cancelAll()/evictAll() unconditionally, but ManagedChannel has no API to cancel in-flight RPCs without closing the channel, so there is no counterpart here.
  • The executor field is left alone: it comes from ExtendedGrpcSenderConfig.getExecutorService() and is caller-owned.
  • JdkHttpSender remains in Standardize sender shutdown implementations #8280, so this PR does not close it.

Testing done

  • Added UpstreamGrpcSenderTest: shutdown_ManagedChannel_WaitsForChannelTermination, shutdown_UnmanagedChannel_ReturnsImmediatelyAndLeavesChannelOpen, shutdown_ChannelDoesNotTerminateInTime_Succeeds. A fake ManagedChannel controls termination timing. The first fails against the previous implementation.
  • ./gradlew :exporters:sender:grpc-managed-channel:check — 3 tests passed. The module had no test source set before; no build script change needed.
  • No apidiff or CHANGELOG entry: internal package, signature unchanged, matching Standardize OkHttpHttpSender shutdown to await executor termination #8495.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.60%. Comparing base (b86f040) to head (300b1f6).

Files with missing lines Patch % Lines
...pc/managedchannel/internal/UpstreamGrpcSender.java 84.61% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8624      +/-   ##
============================================
- Coverage     91.60%   91.60%   -0.01%     
- Complexity    10343    10345       +2     
============================================
  Files          1013     1013              
  Lines         27352    27365      +13     
  Branches       3215     3216       +1     
============================================
+ Hits          25057    25068      +11     
- Misses         1567     1569       +2     
  Partials        728      728              

☔ 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.

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.

1 participant