Skip to content

[Serve][2/2] Propagate TracingConfig to proxies at startup - #65437

Merged
abrarsheikh merged 18 commits into
ray-project:masterfrom
suppagoddo:tracing-config-2of2
Nov 17, 2026
Merged

abrarsheikh merged 18 commits into
ray-project:masterfrom
suppagoddo:tracing-config-2of2

Conversation

@suppagoddo

@suppagoddo suppagoddo commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #63273 ([1/2]), completing the TracingConfig feature.

Problem

In #63273, TracingConfig reached replicas but never reached proxies: ProxyActor gained an optional tracing_config argument, but nothing passed it, so proxies always fell back to their own RAY_SERVE_TRACING_* env vars. Declarative configs (serve deploy, serve run <config.yaml>) were applied only after the controller and proxies had already started. A later serve deploy could replace the stored config, but that only affected replicas started afterwards; running proxies and replicas kept their original tracing setup, with no error.

OpenTelemetry allows one tracer provider per process, so a running component can't adopt a new tracing config.

Design: tracing is fixed when Serve starts

  • Delivered at controller creation by every entry point: serve.start, serve_start_async (used by serve deploy), and serve run <config.yaml>.
  • Proxies receive it as a constructor argument (through ProxyStateManager, the same way as logging_config) and set up tracing once in __init__. Replicas read it from the controller when they start.
  • Changes are rejected. After Serve has started, a different tracing config raises Tracing config cannot be changed after Serve has started, whether it comes from serve deploy / apply_config or a second serve.start call. Re-applying the same config does nothing. To change tracing, shut down and restart Serve.

How the config is resolved

  • The caller validates TracingConfig and passes only the explicitly set fields (model_dump(exclude_unset=True)) to the controller. The controller builds the effective config in its own process, so omitted fields default from the controller's env vars, which can be set via controller_options.runtime_env.env_vars. Explicit values always win.
  • exporter_import_path defaults to RAY_SERVE_TRACING_EXPORTER_IMPORT_PATH, or the built-in file exporter if that's unset. An explicit "" is now a validation error. The defaults for enabled and sampling_ratio are unchanged.
  • apply_config receives a ServeDeploySchema already built by the dashboard. It compares that request's explicit tracing fields against the running config, resolved the same way, before changing any controller state.

Controller recovery

There is no tracing checkpoint and no long poll. When the controller restarts, Ray replays its constructor argument (the explicit fields), so it reproduces the same effective config under the same controller environment. New proxies and replicas created after recovery get it the same way as before the restart.

Startup failures

  • The controller validates the exporter when it's first constructed, before writing any state:
    • It must import. A custom exporter must be a zero-argument function. The controller calls it once, checks that it returns a List[SpanProcessor], and shuts the returned processors down. It doesn't install a tracer provider.
    • The built-in exporter is only imported, because calling it opens a span file. OpenTelemetry must be installed when tracing is enabled.
    • Any failure fails construction with InvalidTracingConfigError (a ValueError): an unimportable exporter, a bad signature, an exporter that raises or returns the wrong type, or missing OpenTelemetry. serve.start and serve_start_async raise it, and serve deploy returns a 400.
    • Ray doesn't restart an actor whose constructor raised, and it releases the controller's name. So a retry with the same exporter fails again, and a retry with a corrected exporter starts Serve, with no serve.shutdown() in between.
  • On a controller restart after a crash, the exporter isn't called again. The import and signature checks only log a failure, so recovery isn't blocked.
  • Custom exporters must return promptly, because the controller calls them during startup. Proxies and replicas still call them when they set up tracing, as before.
  • Known limitation: an exporter can pass in the controller but fail in a proxy or replica, for example because of a node-specific environment. That's handled like any other startup failure: Serve's existing recovery replaces the proxy, and a replica failure fails the deployment.
  • Otherwise, proxy startup failures and readiness timeouts behave as on master.

Behavior changes relative to master

  • Proxies now use TracingConfig instead of only their own env vars.
  • serve deploy and serve run <config.yaml> apply tracing_config when the controller is created.
  • Omitted tracing fields default from the controller's env vars, not from whichever process built the config.
  • Changing tracing after startup raises an error. On master, apply_config replaced the config silently, and only replicas started later picked it up.
  • An explicit exporter_import_path="" is rejected. On master it meant "use the built-in exporter".
  • TracingConfig().exporter_import_path is now the built-in exporter's path (or the env var) rather than "".
  • Invalid exporters fail at controller startup with a config error (a 400 from serve deploy) instead of failing later during proxy or replica startup. That covers exporters that can't be imported, have a bad signature, raise when called, or return the wrong type. On master, an exporter that raised failed proxy startup and left the controller running.
  • A custom exporter is now also called once in the controller, at initial startup.

Testing

Ran locally:

  • Unit tests:
    • TracingConfig defaults and validation.
    • Explicit fields resolving under another environment.
    • Exporter validation:
      • Signature checks.
      • A valid exporter is called once, every processor it returns is shut down once, and no tracer provider is installed.
      • An exporter that raises is rejected.
      • Invalid output (not a list, a tuple, or a valid processor followed by an invalid item) is rejected, and the valid processors are still shut down.
      • A processor shutdown failure is logged without hiding the validation error.
      • The built-in exporter isn't called.
      • The exporter isn't called on controller recovery.
      • Missing OpenTelemetry is reported.
      • Disabled tracing calls nothing.
    • Recovering the original exception from a pickled ActorDiedError.
    • Proxy startup errors and readiness timeouts are re-raised as on master, on sync and async paths.
  • Results: test_controller.py 79 passed, test_tracing_utils.py exporter-validation tests 22 passed, test_proxy.py 43, test_proxy_state.py 38, TracingConfig schema tests 14.
  • black, ruff, mypy and pyrefly at the versions pinned in .pre-commit-config.yaml.

Pending CI (these need a Ray cluster):

  • Imperative, serve deploy (REST and CLI) and serve run tracing flows.
  • A partial config resolving from controller_options.runtime_env.
  • Invalid exporters, including one that raises when called, returning ValueError / 400.
  • Bad → bad → good retries on the sync and async paths, with explicit and controller-env config, without serve.shutdown().
  • An exporter that fails only in replicas failing the deployment.
  • Rejected runtime changes, including the CLI message and the no-state-mutation check.
  • Controller recovery, including spans from a newly created proxy and replica.
pytest python/ray/serve/tests/unit/test_schema.py -k TracingConfig
pytest python/ray/serve/tests/unit/test_controller.py
pytest python/ray/serve/tests/test_tracing_utils.py
pytest python/ray/serve/tests/test_standalone.py -k "tracing or exporter"
pytest python/ray/serve/tests/test_cli.py -k tracing
pytest python/ray/serve/tests/test_cli_3.py -k tracing
pytest python/ray/dashboard/modules/serve/tests/test_serve_dashboard.py -k tracing

Not a duplicate

This is part 2 of the work started in #63273; no other open PR covers delivering the tracing config to proxies and replicas. Follow-up: #66382 (pass the config to replicas as a constructor argument instead of an RPC at startup).

This PR used Claude Code for writing code.

@suppagoddo
suppagoddo requested a review from a team as a code owner August 12, 2026 20:09

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces dynamic reconfiguration and checkpointing for global tracing in Ray Serve. It adds a new long-poll namespace GLOBAL_TRACING_CONFIG to broadcast tracing configuration changes from the controller to proxies at runtime, and checkpoints the configuration in the KV store to survive controller recovery. The review identified two critical issues: first, global_tracing_config is not coerced from a dictionary to a TracingConfig object during controller initialization, which could lead to type mismatches; second, removing setup_tracing from ProxyActor.__init__ can cause the initial tracing setup to be skipped entirely during the first long-poll update if self._tracing_config is already set to the same value.

Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/proxy.py Resolved

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

Stale Bugbot comment from a previous run.

Comment thread python/ray/serve/_private/proxy.py Resolved
Comment thread python/ray/serve/_private/proxy.py Resolved
@suppagoddo
suppagoddo marked this pull request as draft August 12, 2026 21:12
@suppagoddo
suppagoddo marked this pull request as ready for review August 12, 2026 23:16

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request implements dynamic reconfiguration and checkpointing for global tracing configurations in Ray Serve, allowing proxies to receive tracing updates at runtime via long polling and ensuring the configuration survives controller recovery. Feedback is provided regarding a potential runtime NameError in _coerce_tracing_config if TracingConfig is not imported at the module level, suggesting a local import to resolve the issue safely.

Comment thread python/ray/serve/_private/controller.py Resolved
@suppagoddo
suppagoddo force-pushed the tracing-config-2of2 branch from 113a295 to e014365 Compare August 12, 2026 23:19
@jeffreywang88 jeffreywang88 added the go add ONLY when ready to merge, run all tests label Aug 13, 2026
@ray-gardener ray-gardener Bot added serve Ray Serve Related Issue community-contribution Contributed by the community labels Aug 13, 2026
@jeffreywang88 jeffreywang88 self-assigned this Aug 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Aug 27, 2026
Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/replica.py Resolved
@jeffreywang88 jeffreywang88 removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 9, 2026
@johntaylor-cell

Copy link
Copy Markdown
Contributor

test_cli.py:110 After a rebase this test leaves the session-scoped proxies traced at ratio 1.0 for the rest of the file, because #65432's enabled=False finalizer resets only the controller and replicas.

suppagoddo added a commit to suppagoddo/ray that referenced this pull request Sep 11, 2026
…setup

Addresses review feedback on ray-project#65437: a bad `exporter_import_path` was only
resolved lazily via `import_attr`, so an invalid path passed pydantic
validation, got checkpointed and broadcast, and only blew up later — crashing
replicas (whose `setup_tracing` call had no error handling) and reloading on
controller recovery.

- Add `validate_tracing_exporter_import_path` to tracing_utils. It mirrors
  `setup_tracing`'s path resolution (default when empty, only when enabled) and
  calls `import_attr` so a bad path raises.
- Controller: call it in `reconfigure_global_tracing_config` after coercion and
  before checkpointing, so `serve deploy` / `apply_config` fails fast and an
  invalid path is never persisted or broadcast. Validation runs only on this
  user-input path, not in the constructor, so controller recovery from a
  (now-always-valid) checkpoint can't crash-loop.
- Replica: wrap `setup_tracing` in try/except and log-and-continue, matching the
  proxy's long-poll handler. Still needed as defense-in-depth: the controller
  resolves the path against the head node, so a path importable there may not
  import on a worker node.
- Tests: unit-test the validator (disabled skips, empty falls back to default,
  bogus path raises).

Signed-off-by: uditagrawal <[email protected]>
suppagoddo added a commit to suppagoddo/ray that referenced this pull request Sep 12, 2026
Address the remaining review feedback on ray-project#65437 (test hardening + visibility):

- controller: log the resolved global tracing config at INFO on the initial
  snapshot and on every runtime change. Env vars are now read controller-side,
  so this is the only place the effective, cluster-wide config is visible.
- test_standalone: the imperative-flow test asserted only that span *files*
  exist, but the file exporter opens the file at setup time, so that passed
  even if no span was emitted. Assert on file *contents* instead (replica emits
  `application_span`, proxy emits `proxy_http_request`) via a shared helper.
- test_standalone: add two tests -- enabling tracing at runtime reaches an
  already-running proxy over the long poll and it starts emitting spans; and a
  bad `exporter_import_path` is rejected by the controller before it is
  checkpointed/broadcast, leaving the previous config in effect.
- test_proxy: unit-test that `_update_tracing_config` swallows a setup failure
  (bad exporter path) and leaves setup unsucceeded so a later delivery retries,
  matching the long-poll-callback contract.

Signed-off-by: uditagrawal <[email protected]>

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

Stale Bugbot comment from a previous run.

Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/controller.py Resolved
Comment thread python/ray/serve/_private/proxy.py Resolved
Comment thread python/ray/serve/_private/replica.py Resolved
@suppagoddo

suppagoddo commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@jeffreywang88 @johntaylor-cell - Thank you so much for the review!! Addressed all your comments

@jeffreywang88 jeffreywang88 left a comment

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.

thanks for the updates! one last blocking comment. can we also rewrite the code comments to be less-claudish? claude is unfortunately not good at writing :(

Comment thread python/ray/serve/_private/replica.py Resolved
@suppagoddo

Copy link
Copy Markdown
Contributor Author

I created the gh issues and linked to this PR. Changed all the comment to human readable.

@suppagoddo

Copy link
Copy Markdown
Contributor Author

@jeffreywang88 - I am thinking of writing a blog post on how to enable this and use this new feature, can you provide some pointers? I am thinking to adding this blog to Ray docs/tutorial or if there is any other place you think would be better

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Nov 1, 2026
@johntaylor-cell

Copy link
Copy Markdown
Contributor

Re-reviewed after the redesign. I agree with Abrar's open comments, plus three small things:

  1. Please also call _validate_tracing_exporter in check_tracing_exporter_import_path as an exporter that takes arguments now passes the controller, then fails proxy startup with a 500 from serve deploy.
  2. Please say in the TracingConfig and serve.start docstrings that tracing is fixed when Serve starts and changing it requires restarting Serve.
  3. Please fix the description before merge. GLOBAL_TRACING_CONFIG, _update_tracing_config and validate_tracing_exporter_import_path never existed on master, and master already raised on tracing setup failure.

@suppagoddo

Copy link
Copy Markdown
Contributor Author

@johntaylor-cell - Thanks for the re-review. Is my understanding below sounds good:

So here is what I am thinking:
Since we still want unset fields to resolve from the controller env, I am thinking the caller can validate the config but pass only the explicitly-set fields (model_dump(exclude_unset=True)) to the controller. The controller would then construct the effective TracingConfig once in its own process.

That would remove _resolve_tracing_config and the model_fields_set workaround while preserving the controller-env behavior we discussed. Does that direction make sense to you?

@johntaylor-cell johntaylor-cell removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Nov 2, 2026
@johntaylor-cell

Copy link
Copy Markdown
Contributor

@johntaylor-cell - Thanks for the re-review. Is my understanding below sounds good:

So here is what I am thinking:
Since we still want unset fields to resolve from the controller env, I am thinking the caller can validate the config but pass only the explicitly-set fields (model_dump(exclude_unset=True)) to the controller. The controller would then construct the effective TracingConfig once in its own process.
That would remove _resolve_tracing_config and the model_fields_set workaround while preserving the controller-env behavior we discussed. Does that direction make sense to you?

Not quite. Abrar's default_factory change already removes the model_fields_set workaround, and apply_config still gets tracing_config as a model built in the dashboard, so the controller would still rebuild it there. @abrarsheikh, since you raised _resolve_tracing_config, keep that one rebuild in the controller, or resolve defaults where the config is built, as LoggingConfig does?

@suppagoddo

Copy link
Copy Markdown
Contributor Author

Thanks @johntaylor-cell , that makes sense. Will wait for @abrarsheikh's input on whether we should keep controller-side resolution or follow the existing LoggingConfig pattern.

I will also address your three review comments around exporter validation, docstrings, and the PR description.

dstrodtman added a commit that referenced this pull request Nov 4, 2026
## Description

This PR makes the `lint: API param coverage` step a required check by
removing `soft_fail: true`. The step was added in #64788 on 2026-08-11.
A comment in the step said to remove `soft_fail` "once the
false-positive rate is confirmed low." This PR measures that rate from
the step's CI history and fixes the four failure patterns the history
turned up.

While the step only warns, undocumented parameters still land on master.
#65633, #66602, and #66950 all merged with the check failing.

### Warn-phase metrics

These numbers come from every `premerge` build from 2026-08-11 to
2026-10-29, pulled from the Buildkite API.

| | Runs | PRs |
|---|--:|--:|
| Completed runs of the step | 3,453 | |
| Passed | 3,398 | |
| Failed | 55 | 23 |
| Canceled, which isn't a check outcome | 211 | |

Each failure falls into one of three groups:

| Failure type | PRs | Runs | Detail |
|---|--:|--:|---|
| Correct finding | 15 | 42 | A new parameter on a `@PublicAPI` callable
has no `Args:` entry. Two of these PRs, #65823 and #65839, were stacked
on #65633 before it merged and report its findings again. |
| False positive | 3 | 4 | #64399 flagged the `v` argument of a pydantic
`@field_validator`. #66255 flagged the private kwarg `_direct_http`.
#67258 flagged an option of the `ray start` Click command, which `help=`
documents. |
| Infrastructure | 5 | 9 | The step printed `could not determine
merge-base` and no findings. The branches of #65437 and #65809 forked
520 and 598 master commits before their builds. The step's `git fetch
--depth=500` makes the full CI clone shallow, so their merge-base wasn't
in the fetched history. |

That's 13 spurious failures out of 3,453 runs, about 0.4%, or 13 of 55
failures. Each one would block a PR once the step is required, so this
PR fixes all four patterns before removing `soft_fail`.

### Changes

- **`_`-prefixed parameters:** `api_param_coverage.py` skips parameters
whose names start with `_`. That's Ray's convention for private kwargs,
such as `ray.put(_owner=...)`, `tune.run(_remote=...)`, and
`Deployment.options(_internal=...)`. On master, 31 public callables have
such parameters.
- **Pydantic validators and Click commands:** The script skips callables
decorated with `field_validator`, `model_validator`, `validator`,
`root_validator`, `command`, or `group`. On master, this removes 59
callables from scope. All of them are Click commands, such as `ray
start` and `ray job submit`, or pydantic validators on Serve config
models. None of them is a Python API whose parameters a docstring
documents.
- **Property setters:** The script also skips callables decorated with
`@<name>.setter`. A setter's `value` is documented on the property's
getter, which is the docstring Sphinx renders, not in an `Args:` section
of its own.
- **Shallow-clone merge-base:** When `git merge-base` fails after the
depth-500 fetch, `ci/lint/lint.sh` runs `git fetch --unshallow` and
retries. A branch within 500 commits of the base never reaches that
path. The Python check still fails closed if the base can't be resolved
after that.
- **Step definition:** `.buildkite/lint.rayci.yml` drops `soft_fail:
true` and the warn-phase comment. The `--blocking` help text in
`cmd_check_api_param_coverage.py` no longer describes a warn phase.

## Related issues

Follow-up to #64788.

## Additional information

### Testing

- `pytest ci/ray_ci/doc/test_api_param_coverage.py`: 40 passed. That's
the 28 existing tests plus 12 new cases covering `_` params, each
validator spelling, Click command forms, and property setters. The test
comments name the real PR that motivated each one.
- **Replay against real PRs:** I ran the master and patched versions of
the check against the exact commit and base of every failing run in each
of the 18 PRs with findings. Master reproduces all 18 failures. The
patched check passes #64399, #66255, and #67258, and reports the same
findings as master on the other 15.
- **Merge-base fix:** In a local repo with 600 commits on `master` and a
branch forked at commit 50, `git fetch --depth=500` followed by `git
merge-base` fails, which reproduces the CI failure. With the new
`lint.sh` block, it resolves the correct fork commit. A branch forked 10
commits back resolves without the fallback.
- `pre-commit run` on the changed files passes, including ruff, black,
shellcheck, and docstyle.

### Duplicate check

`gh pr list --state open --search "param coverage"` and `--search
"api_param_coverage"` return no open PR that touches this check. The
script hasn't changed since #65391 on 2026-08-14.

### AI assistance

I used Claude Code to pull and classify the Buildkite history, draft the
changes, and run the replay. I reviewed every changed line and the
classification of every failing PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@abrarsheikh

Copy link
Copy Markdown
Contributor

@suppagoddo

That would remove _resolve_tracing_config and the model_fields_set workaround while preserving the controller-env behavior we discussed. Does that direction make sense to you?

this makes sense to me

…lean up failed starts

Address review from abrarsheikh and johntaylor-cell:

- TracingConfig: exporter_import_path defaults via default_factory to
  RAY_SERVE_TRACING_EXPORTER_IMPORT_PATH, else the built-in exporter; an
  explicit empty path is rejected. Drop the after-validator and the
  model_fields_set workaround.
- The caller validates the tracing config and passes only its explicitly set
  fields (model_dump(exclude_unset=True)); the controller builds the effective
  config, so omitted fields default from the controller's env. Remove
  _resolve_tracing_config. apply_config compares a candidate built from the
  request's explicit fields against the config Serve started with.
- Rename reconfigure_global_tracing_config to check_tracing_config.
- Validate custom exporter signatures at controller startup (without calling
  them); the built-in exporter is exempt.
- If a proxy fails to start, serve.start / serve_start_async shut down the
  controller that call created (graceful_shutdown, falling back to kill) and
  re-raise the original error, so a retry doesn't connect to a broken instance.
  Proxy readiness timeouts are unchanged.
- _get_actor_init_error reads RayTaskError.cause.
- Document that tracing is fixed when Serve starts.

Tests: TracingConfig defaults/validation, exporter signature checks, startup
cleanup (unit, sync and async), retries after a failed start, CLI rejection
message, REST 400 for a bad exporter signature, and spans from a new proxy and
replica after controller recovery.

Signed-off-by: uditagrawal <[email protected]>

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

Stale Bugbot comment from a previous run.

Comment thread python/ray/serve/_private/api.py Resolved
…-start shutdown hangs

Killing it with no_restart=True left SHUTDOWN_IN_PROGRESS_KEY in the KV store,
so the next controller shut itself down and a corrected retry failed. The
restarted controller resumes the shutdown, deletes the key and exits.

Signed-off-by: uditagrawal <[email protected]>
- test_tracing_works_after_controller_recovery: wait for the recovered
  controller to list the existing proxy before replacing it; get_proxies()
  is empty until its first control loop runs.
- test_http_proxy_callback_failures: a failing proxy callback now fails
  serve.start, which shuts down the Serve instance it created, so assert
  that each retry fails the same way and no instance is left behind.

Signed-off-by: uditagrawal <[email protected]>

@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 using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 72209a1. Configure here.

Comment thread python/ray/serve/_private/api.py Resolved
@suppagoddo

Copy link
Copy Markdown
Contributor Author

Thanks @abrarsheikh and @johntaylor-cell for the detailed feedback.

I've pushed the updates addressing the remaining review comments.

The configuration flow now follows the explicit-fields approach we discussed: the caller validates and sends only explicitly set fields, and the controller constructs the effective TracingConfig using its environment. The old _resolve_tracing_config and model_fields_set workaround are removed.

The controller now uses check_tracing_config to reject runtime changes. I also updated the exporter defaults and validation, exception handling, and the CLI assertions.

For the startup failure concern, I've added cleanup for both sync and async paths and tests covering retries with a failing exporter followed by a working one. The cleanup also handles the shutdown-state issue identified in the subsequent Cursor review.

I've added a recovery test that checks actual tracing spans from a newly created proxy and replica after controller restart.

Other proxy startup failures keep master's behavior: the controller stays up
and replaces the proxy. The proxy now raises TracingSetupError when
setup_tracing fails, and serve.start / serve_start_async shut down the
controller they created only for that error.

The cleanup no longer kills or restarts the controller, so it can't orphan
SHUTDOWN_IN_PROGRESS_KEY, and it confirms the controller exited by checking
that its name was released rather than trusting a RayActorError.

Signed-off-by: uditagrawal <[email protected]>
@suppagoddo

suppagoddo commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

@abrarsheikh, I think the current tracing-specific shutdown adds unnecessary complexity. I'm particularly concerned about the 30s timeout, since it doesn't guarantee cleanup. I'd prefer a simpler approach:

  • Bad config: Return an error instead of false success.
  • Controller: Keep it alive and preserve existing proxy recovery.
  • Corrected config: Require explicit serve.shutdown() before retrying.

This differs from your original request, but avoids introducing additional lifecycle handling for tracing. Would this be acceptable?

…led-start cleanup

The controller now calls a custom exporter factory once when it's first
constructed, validates the returned span processors and shuts them down. An
exporter that raises or returns the wrong type fails controller construction
with InvalidTracingConfigError, so Ray releases the controller's name and a
corrected serve.start / serve deploy retry starts fresh without shutdown.

The factory isn't called again when the controller is reconstructed, and the
built-in exporter is never called. This replaces the tracing-specific shutdown
after a failed proxy start, which is removed along with TracingSetupError;
proxy startup failures behave as on master.

Signed-off-by: uditagrawal <[email protected]>
Under Bazel, importing ray.serve.tests.test_tracing_utils by path loads a
second copy of the test module, so the exporters updated counters the tests
couldn't see. Patch import_attr to return this module's function instead.

Signed-off-by: uditagrawal <[email protected]>
@abrarsheikh
abrarsheikh merged commit 4f3096d into ray-project:master Nov 17, 2026
6 checks passed
eugenepaniot added a commit to eugenepaniot/ray that referenced this pull request Nov 19, 2026
…floop-input

* upstream/master:
  [Data][3/n] update progress bar on lineage reconstruction (ray-project#67366)
  [Data] Enable the Top-N rewrite by default and expose it on DataContext (ray-project#68329)
  [Data] Adaptively skip map-side partial aggregation for high-cardinality keys (ray-project#68118)
  [Core] Spawn specific servers without preexec_fn to fix intermittent startup crashes (ray-project#67947)
  [Serve] Stop the __wrapped__ walk at non-callables (ray-project#67117)
  [Data] Deflake test_read_parquet_v2 by cutting redundant Ray Data executions (ray-project#68318)
  [Data] Retry FooterReader actor deaths with Ray Core and yield footers in listing order (ray-project#67988)
  [Data] Fix order-dependent schema unification when a list<null> arm is present (ray-project#68259)
  [Serve] Make @serve.batch work when wrapped in another decorator (ray-project#68177)
  [serve] Deflake test_metrics_3 - record the batch queue length once a batch is taken (ray-project#68302)
  [serve] Drop completed requests from the multiplexed model ID index (ray-project#68085)
  [Data] Fix flaky test_hudi: read each table once instead of sorting in Ray Data, keep size small (ray-project#68162)
  [Data] Fix flaky test_context: start 2 Ray clusters instead of 5 and keep size small (ray-project#68161)
  [Data] Fix flaky test_kafka: use recent timestamps in test_read_kafka_datetime_partial_range (ray-project#68248)
  [Data] Iceberg DSv2 [2/5]: The listing-to-reading manifest for Iceberg (ray-project#67951)
  [Train] Report training errors when the post-mortem debugger raises a BaseException (ray-project#68317)
  [RLlib] Skip the PPOConfig docstring example that crashes the rllib doctest target (ray-project#68306)
  [Train] Support post-mortem debugging for training function errors (ray-project#68296)
  [train][1/n] Give each health probe its own timeout (ray-project#68191)
  [Data] Fix unifying a fixed-shape tensor array with a lower-ndim variable-shaped one (ray-project#67266)
  [Train] Add a guide to debugging failures and hangs (ray-project#68299)
  [Data] Persist BlockMetadata.num_rows and batch ray.get in _calculate_blocks_rows (ray-project#67662)
  [Data] Vectorize LeRobot delta segment preparation and validate index contiguity (ray-project#67845)
  [Data] Avoid full-DataFrame apply in _AbstractKBinsDiscretizer._transform_pandas (ray-project#67862)
  [doc] Refresh intersphinx inventory snapshots (ray-project#68303)
  [Data] Fix SimpleImputer on categorical columns in append mode and with existing category values (ray-project#67467)
  [Data] Replace O(N) list.pop(0) with deque.popleft() in PushBasedShuffleTaskScheduler (ray-project#67243)
  [Train] Reject an elastic ScalingConfig with max_workers=0 (ray-project#68218)
  [core][move semantics][3/n]Populate task args with is_move for movable refs (ray-project#66803)
  [core][sandbox] Remove the readonly option (ray-project#68088)
  [Data](1/n) Implement the line-chunk reader for CSV and JSONL on DataSource V2 (ray-project#67907)
  [Data] Set MIMALLOC_PURGE_DELAY=0 on random_shuffle to fix the pyarrow 25 OOM regression (ray-project#68151)
  [core] Quote each `uv run` argument in the uv runtime env hook (ray-project#68156)
  [core] Don't let gRPC cancel calls that wait over 30s in the server queue (ray-project#68210)
  [Data] Fix shuffle and join on native tensor columns with pyarrow 25+ (ray-project#68072)
  [serve][llm] Remove decode load progress (ray-project#68258)
  [ci] Bump sglang to 0.5.23 in release tests (ray-project#68250)
  [Core] Build the test auth token file locally so Windows tests can read it (ray-project#68262)
  [image] Bump EFA installer to 1.51.0 in CPU base-extra images (ray-project#67730)
  [serve] Observe the result of rank reassignment reconfigures (ray-project#67923)
  [Serve][Docs] Explain imperative vs declarative deploys and in-place updates from Python (ray-project#68243)
  [Data] (Fault tolerance) Ray Data lineage reconstruction docs (ray-project#68061)
  [RLlib] Add a multi-node footsies APPO memory release test (ray-project#67595)
  [Train] Remove local mode (ray-project#68239)
  [Data] Fix filtered Lance row-count metadata (ray-project#67228)
  [Serve][2/2] Propagate TracingConfig to proxies at startup (ray-project#65437)
  [Data] Fix synthesized path filtering in DataSourceV2 (ray-project#67079)
  [RLlib] Run the BCConfig Tune example one trial at a time to unblock the rllib doctest target (ray-project#68242)
  [Data][Delta DSv2][2/7] List Delta Lake table files from the log (ray-project#67888)
  [Data] Parallelize Parquet and ORC full-schema reads (ray-project#67542)
  [Data] Random Shuffle on Shuffle V2 Map/Reduce Operators (ray-project#68004)
  [Data] Propagate metadata prefetch thread failures to executor (ray-project#68171)
  [core] Send generator consumed-progress updates from io_service_ (ray-project#67160)
  [Data] Add @ray-data-connectors as codeowner for datasource/sinks files (ray-project#68154)
  [data][llm] Keep the prompt in vLLM error rows (ray-project#67665)
  [data][actor-only][3/n] Actor-only backend: operator fusion (ray-project#67699)
  [Data] Read text files on DataSource v2 (ray-project#68063)
  [Autoscaler][KubeRay] Never patch worker group replicas below minReplicas (ray-project#67332)
  [Serve] Show progress of updating (ray-project#67107)
  [core][test] Trigger usage-stats OOM test without exhausting host memory (ray-project#68009)
  [Serve] Remove unused RAY_SERVE_HAPROXY_INGRESS_RETRY_ON and RAY_SERV… (ray-project#68175)
  [Data] Implement lineage tracker garbage collection upon marking operator durable (ray-project#67788)
  [Core] Fix recovery suppression race in ObjectRecoveryManager (ray-project#64974)
  [serve] Pass grpc.so_reuseport to gRPC as an integer (ray-project#66816)
  [Autoscaler][v2] Preserve retry accounting when trimming status history (ray-project#67360)
  [doc] Refresh intersphinx inventory snapshots (ray-project#68069)
  [Doc] Add item to AGENTS.md to update documentation when modifying API-facing code. (ray-project#68204)
  [Train] Preserve `num_boost_round=0` and avoid mutating `callbacks` in legacy LightGBM/XGBoost trainers (ray-project#68145)
  [Train] Raise in prepare_data_loader instead of dropping a custom batch_sampler (ray-project#68201)
  [air] Return None in skip_exceptions when exc or StartTraceback cause is None (ray-project#68172)
  [Train] Fix `checkpoint_manager` to support metrics only reported in a validation function (ray-project#67909)
  [Train] Count elastic workers in resource units for fractional resources (ray-project#68139)
  [Data] Refactor Disk shuffle map to use map Operator (ray-project#67130)
  [core][move semantics][2/n] Change state to moved on consumption and add enforcements (ray-project#66767)
  [Data] Propagate labels to object-store SHUFFLE_V2 map/reduce tasks (ray-project#67135)
  feat(core): add Cambricon MLU resource support (ray-project#66368)
  [Data] Make `zero_copy_batch=False` copy default batches (ray-project#67154)
  [data] Fix Parquet filename suffix detection (ray-project#67156)
  [data] Fix docstring/behavior mismatches in read_json and Dataset.sort (ray-project#66927)
  [Data] Run video_object_detection.ray on T4s with more memory (ray-project#68149)
  [core][sandbox] Let a node override network="public" sandboxes' default resolvers (ray-project#67691)
  [Data] read_mcap: resolve each sample's steps and lay out its row (ray-project#67925)
  [Data] read_mcap: sample read inputs: TopicSpec, steps, match and samples checks (ray-project#67924)
  [Data] Keep a map task's buffered rows when max_errored_blocks skips its error; read past corrupt MCAP chunks (ray-project#67167)
  [core][move semantics][1/n] Adding consume_once flag in actor methods (ray-project#66620)
  [Data] Size the schema pin and the columns Ray adds in the Parquet decoded-size estimate [3/6] (ray-project#67838)
  [Serve][LLM][1/3] Token based autoscaling: track autoscaling workload in KV router (ray-project#67937)
  [Data] Add native direct reads for nonpartitioned Hive tables (ray-project#67114)
  [Train] Count elastic workers in resource units for fractional resources (ray-project#68139)
  [Data] Add `condition` to `Dataset.join` and extract equi-join keys from it (ray-project#67590)
  [data] Add Top-N execution (ray-project#66931)
  [build] Bazel 8.8.1: bump protobuf to v29.6, rules_java to 8.12.0 and gRPC to 1.69.0 (ray-project#66483)
  [build] Use Arena::Create and pin Java 8 bytecode ahead of protobuf 29 / rules_java 8 (ray-project#67720)
  [core][sandbox] Don't join a sandbox's cgroup on every exec (ray-project#67690)
  [Data] Run `training_ingest_regression_test` on Instances that can be Provisioned (ray-project#68110)
  [Data] Run Sort on Disk-based Shuffle under SHUFFLE_V2 (ray-project#67850)
  [core] Deflake tests that race on timing (ray-project#67717)
  [ci] Bump pypa manylinux2014 base image to 2026.10.22-0 for CPython 3.15 (ray-project#67285)
  [Data] Make Mcap Data Column Test Insensitive to Struct Field Order (ray-project#68109)
  [Data] read_mcap V2: cut large files where their log-time order holds (ray-project#67166)
  [core][sandbox] Commit sandbox as new registry image (ray-project#67972)
  [Data] read_mcap V2: read neighbouring chunks in one ranged request (ray-project#67930)
  [train][4/n] Wire WorkerProbes through the HealthManager (ray-project#67915)
  [train][3/n] Add WorkerProbe results and health reports to the HealthState (ray-project#67879)
  [Data] (Data fault tolerance ray-project#6/6) Add a manual release test for lineage reconstruction (ray-project#67519)
  [train][6/n] Act on health decisions in the Ray Train controller (ray-project#67856)
  [Train] Do not start an elastic worker group with zero workers (ray-project#68101)
  [Train] Keep the last checkpoint after a metrics-only report in local mode (ray-project#68070)
  [Data][2/n] Migrate GPU Shuffle to Unified Phase Metrics (ray-project#67359)
  [Data][Chkpt] Fix `ArrowInvalid` when loading large generated-ID checkpoints (ray-project#68065)
  [core][test] Create auth token in test_redis_wrong_password (ray-project#68014)
  [data][actor-only][2/n] Actor-only backend: promote task pools to actor pools (ray-project#67698)
  [Data] Fix typing mismatches in Dataset public API (ray-project#62077)
  [Data] read_mcap V2: carry read tasks' summary records in the manifest (ray-project#67929)
  [Data] Distinguish generated ID collisions with synthesized columns (ray-project#67164)
  [Data] Fix incorrect scale-up in rate-based autoscaler for custom resources (ray-project#66647)
  [Data][Delta DSv2][1/7] Shared Parquet and partitioning fixes for the Delta reader (ray-project#67887)
  [Data] Eliminate redundant aggregation shuffle (ray-project#67198)
  [Data] Raise minimum supported pyarrow to 23.0.0 and test up to 26.0.1 (ray-project#68005)
  [Train] Use the default validation timeout when a report's ValidationTaskConfig has none (ray-project#68045)
  [doc][train] Use the global batch size in the TensorFlow Train examples (ray-project#68006)
  [TPU] Default multi-slice MASTER_ADDR to slice 0 host 0 in SlicePlacementGroup (ray-project#67878)
  [Data] Estimate a Parquet row group's decoded Arrow bytes from its footer [2/6] (ray-project#67837)
  [Data] Predicate pushdown through joins: split conjuncts, derive one-sided OR weakenings (ray-project#67122)
  [Data] Add partition_filters to read_delta and take file sizes from the log (ray-project#67900)
  [Data] Stop writing Unity Catalog vended credentials to the environment (ray-project#67899)
  [Data] Raise an error for Delta tables with column mapping in write_delta (ray-project#67898)
  [Core] Add initial foundational configurations and flags for fork server (ray-project#67356)
  [core][sandbox] Image layers caching (ray-project#67874)
  [Doc][Train] Add device stream batch prefetching section to accelerator guide (ray-project#67779)
  [Train] Use user-defined train function name in training thread name and error stack traces (ray-project#64292)
  [serve][docs] Remove beta label from custom autoscaling policies (ray-project#68046)
  [core] Don't treat a gRPC client with calls in flight as idle (ray-project#67718)
  [train] Fix checkpoint sorting to support nested metrics (ray-project#59130)
  [train][5/n] Run ControllerProbes on the controller's node monitor (ray-project#67671)
  [Train] Rank a checkpoint without the score attribute as worst in min order (ray-project#67901)
  [Core][RuntimeEnv] Stream runtime environment package downloads (ray-project#67184)
  [core] Deflake `_run_hanging_command` tests (ray-project#67461)
  [Data] Add Gravitino Iceberg REST catalog provider (ray-project#67007)
  [Data] Fix mixed-root partition filtering in Parquet and ORC V2 (ray-project#67067)
  [core] Keep absl logging at ERROR unless GRPC_VERBOSITY is set (ray-project#67719)
  [Data][1/n]Add Shuffle Metrics Unification Instrumentation (ray-project#66968)
  [ci][release] Stop publishing Python 3.10 wheels and images (ray-project#67722)
  [serve] Copy the ASGI lifespan state into each request scope (ray-project#67844)
  [Serve][LLM][4/5] Support scale-to-zero application routing (ray-project#67087)
  [core][sandbox] Let GPU sandboxes request NVIDIA profiling capabilities (ray-project#67974)
  [Serve][LLM] Exclude LLMRouter from dashboard QPS (ray-project#67873)
  [Data] Read the Parquet SizeStatistics PyArrow doesn't expose [1/6] (ray-project#67836)
  Add perf metrics for 2.60.0 (ray-project#67727)
  [Observability / Train] Add Grafana Annotation support with Ray Train usage (ray-project#66958)

Signed-off-by: Eugene Paniot <[email protected]>

# Conflicts:
#	python/ray/data/_internal/planner/plan_udf_map_op.py
dstrodtman added a commit to suppagoddo/ray that referenced this pull request Nov 20, 2026
The full tracing feature, including proxy tracing at startup (ray-project#65437),
ships in Ray 2.61. Replace the nightly-build and alpha caveats with a
single version requirement.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community go add ONLY when ready to merge, run all tests serve Ray Serve Related Issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants