Skip to content

[Serve] Skip tracing test in gRPC mode - #60209

Merged
abrarsheikh merged 5 commits into
ray-project:masterfrom
eicherseiji:trace-ctx-fix
Jan 18, 2026
Merged

abrarsheikh merged 5 commits into
ray-project:masterfrom
eicherseiji:trace-ctx-fix

Conversation

@eicherseiji

@eicherseiji eicherseiji commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Why are these changes needed?

When RAY_SERVE_USE_GRPC_BY_DEFAULT=1, inter-deployment calls use gRPC instead of Ray actor calls. In this mode, _ray_trace_ctx is not injected into kwargs since gRPC calls bypass Ray's tracing decorators.

Tracing context propagation for gRPC mode requires additional work to properly capture and forward the context. This PR skips the test_deployment_remote_calls_with_tracing test in gRPC mode until a proper solution is implemented.

Related issue number

Tracking issue: #60223

Checks

@eicherseiji
eicherseiji requested a review from a team as a code owner January 16, 2026 05:08
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@eicherseiji
eicherseiji force-pushed the trace-ctx-fix branch 2 times, most recently from 3bc85f9 to 457b6c1 Compare January 16, 2026 05:12
@eicherseiji eicherseiji added the go add ONLY when ready to merge, run all tests label Jan 16, 2026
For gRPC requests, _ray_trace_ctx is not injected into kwargs since
there's no Ray actor call. This change:

1. Sets request_meta.tracing_context in the router when tracing is enabled
2. Falls back to request_metadata.tracing_context in _unpack_proxy_args
   when _ray_trace_ctx is not present in kwargs

This ensures tracing context is properly propagated for gRPC inter-deployment
communication.

Signed-off-by: Seiji Eicher <[email protected]>
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling labels Jan 16, 2026
Comment thread python/ray/serve/_private/router.py Outdated
Comment on lines +890 to +895
# Add context to request meta to link
# traces collected in the replica.
if _is_tracing_enabled():
request_meta.tracing_context = _DictPropagator.inject_current_context()
else:
request_meta.tracing_context = None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's revert this change since it's accessing private methods on core. We ca rethink this implementation more generally in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@abrarsheikh shall we skip the test in the meantime?

Reverts the fix that used private Ray core tracing APIs.
Instead, skip the test in gRPC mode until a proper solution
is implemented.

The tracing context propagation for gRPC inter-deployment
requests is tracked in:
ray-project#60223

Signed-off-by: Seiji Eicher <[email protected]>
@eicherseiji eicherseiji changed the title [Serve] Fall back to request_metadata.tracing_context for gRPC tracing [Serve] Skip tracing test in gRPC mode until proper fix Jan 16, 2026
@eicherseiji eicherseiji changed the title [Serve] Skip tracing test in gRPC mode until proper fix [Serve] Fall back to request_metadata.tracing_context for gRPC tracing Jan 16, 2026
Per reviewer feedback, removes the router.py changes that used private
Ray core APIs (_DictPropagator, _is_tracing_enabled) and the test skip.

Keeps only the replica.py fallback logic that reads tracing context from
request_metadata.tracing_context when _ray_trace_ctx is not in kwargs.

Signed-off-by: Seiji Eicher <[email protected]>
@abrarsheikh
abrarsheikh enabled auto-merge (squash) January 16, 2026 18:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread python/ray/serve/_private/replica.py Outdated
# We fall back to using that if _ray_trace_ctx is not in kwargs.
ray_trace_ctx = request_kwargs.pop("_ray_trace_ctx", None)
if ray_trace_ctx is None:
ray_trace_ctx = request_metadata.tracing_context

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fallback relies on field that is never populated

Medium Severity

The fallback to request_metadata.tracing_context will always return None because this field is never populated anywhere in the codebase. The tracing_context attribute in RequestMetadata has a default value of None and no code ever assigns a non-None value to it. This makes the fallback mechanism ineffective for gRPC tracing as described in the PR.

Fix in Cursor Fix in Web

@github-actions
github-actions Bot disabled auto-merge January 16, 2026 22:07

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Comment thread python/ray/serve/_private/replica.py Outdated
ray_trace_ctx = request_kwargs.pop("_ray_trace_ctx", None)
if ray_trace_ctx is None:
ray_trace_ctx = getattr(request_metadata, "tracing_context", None) or {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Empty dict fallback masks missing tracing context

Low Severity

The or {} fallback changes the semantics when neither _ray_trace_ctx nor request_metadata.tracing_context is present. Previously, ray_trace_ctx would be None (indicating no tracing), but now it becomes {} (empty dict). This could mask tracing configuration failures since tests checking _ray_trace_ctx is not None would incorrectly pass with an empty dict, hiding cases where tracing context wasn't properly propagated.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@abrarsheikh request_metadata.tracing_context is not set either, btw, so or {} would be needed to pass the test. Not sure if you had something else in mind; I think this is basically equivalent to skipping the test.

(Until we decide a better way than accessing private Core APIs)

When _ray_trace_ctx is not in kwargs (gRPC path), fall back to
request_metadata.tracing_context or an empty dict. This ensures
the trace context is never None, which allows tracing-aware code
to function without crashing in gRPC mode.

Signed-off-by: Seiji Eicher <[email protected]>
Tracing context propagation is not yet supported when
RAY_SERVE_USE_GRPC_BY_DEFAULT=1 is enabled. Skip the test
until a proper solution is implemented.

Tracked in ray-project#60223

Signed-off-by: Seiji Eicher <[email protected]>
@eicherseiji eicherseiji changed the title [Serve] Fall back to request_metadata.tracing_context for gRPC tracing [Serve] Skip tracing test in gRPC mode Jan 16, 2026
abrarsheikh pushed a commit that referenced this pull request Feb 21, 2026
## Description
Previously in
ba5cd1c,
trace context propagation was extended to Ray Serve. However, it missed
the case for propagating the context through the gRPC path.
#60209 applied a test skip for
the gRPC case as a short-term solution for passing CI until support was
properly extended to gRPC.

This PR extends context propagation support to gRPC by serializing the
trace context into the request.

## Related issues
Fixes #60223

## Additional information
The implementation uses an existing Ray helper function that calls
opentelemetry inject.


https://github.com/ray-project/ray/blob/8882b9045ab8cb3b1764f8b6dbc13aabb1113ff8/python/ray/util/tracing/tracing_helper.py#L165-L170

---------

Signed-off-by: Peter Nguyen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests observability Issues related to the Ray Dashboard, Logging, Metrics, Tracing, and/or Profiling serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants