Skip to content

Preserve current activity for gRPC calls without diagnostics - #2744

Open
mtaghavi2005 wants to merge 1 commit into
grpc:masterfrom
mtaghavi2005:fix-current-activity-propagation
Open

Preserve current activity for gRPC calls without diagnostics#2744
mtaghavi2005 wants to merge 1 commit into
grpc:masterfrom
mtaghavi2005:fix-current-activity-propagation

Conversation

@mtaghavi2005

Copy link
Copy Markdown

Problem

Fixes #2516

Grpc.Net.Client currently creates a fallback gRPC client Activity when Activity.Current is not null, even when gRPC diagnostics, logging, and ActivitySource listeners 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:

  • diagnostic source events
  • logging
  • Grpc.Net.Client ActivitySource listeners

When none of those are enabled, the existing Activity.Current is preserved during send so lower-level HTTP/client instrumentation can propagate the caller's logical context.

Test

Added CurrentActivity_MakeCallWithoutDiagnostics_PreservedDuringSend to verify that Activity.Current is preserved during the send path when gRPC diagnostics are not enabled.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 28, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: mtaghavi2005 / name: Mohammad Taghavi (544194b)

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.

Opentelemetry Trace graph becomes disconnected after creating Grpc Call

1 participant