Preserve current activity for gRPC calls without diagnostics - #2744
Open
mtaghavi2005 wants to merge 1 commit into
Open
Preserve current activity for gRPC calls without diagnostics#2744mtaghavi2005 wants to merge 1 commit into
mtaghavi2005 wants to merge 1 commit into
Conversation
|
|
This was referenced Jun 28, 2026
3 tasks
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.
Problem
Fixes #2516
Grpc.Net.Clientcurrently creates a fallback gRPC clientActivitywhenActivity.Currentis not null, even when gRPC diagnostics, logging, andActivitySourcelisteners are not enabled.That fallback activity was originally added to enable activity propagation. However, it replaces the caller's current logical activity during the send path. In that case, downstream propagation can use the hidden gRPC activity as the parent instead of the caller's activity, which can produce an incorrect parent-child span relationship.
Fix
Only create a gRPC client activity when it is actually needed for:
Grpc.Net.ClientActivitySourcelistenersWhen none of those are enabled, the existing
Activity.Currentis preserved during send so lower-level HTTP/client instrumentation can propagate the caller's logical context.Test
Added
CurrentActivity_MakeCallWithoutDiagnostics_PreservedDuringSendto verify thatActivity.Currentis preserved during the send path when gRPC diagnostics are not enabled.