Skip to content

Conversation

@kamil-kaczmarek
Copy link
Contributor

Description

This PR add prometheus metrics to the selected RLlib components.

@kamil-kaczmarek kamil-kaczmarek self-assigned this Oct 20, 2025
@kamil-kaczmarek kamil-kaczmarek requested a review from a team as a code owner October 20, 2025 22:29
@kamil-kaczmarek kamil-kaczmarek added rllib RLlib related issues go add ONLY when ready to merge, run all tests release-blocker P0 Issue that blocks the release labels Oct 20, 2025
Copy link
Contributor

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

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 Prometheus metrics to various components within RLlib, enhancing observability and monitoring capabilities. The changes are extensive and systematically add timing and counting metrics using a new TimerAndPrometheusLogger and ray.util.metrics. The implementation is consistent and well-structured. My review focuses on improving code clarity and design.

Sparks0219 and others added 11 commits October 20, 2025 15:41
It used to be in 3 different groups, now unionized in 1.

Signed-off-by: kevin <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
…nter (#56848)

* Updated preprocessors to use a callback-based approach for stat
computation. This improves code organization and reduces duplication.
* Added ValueCounter aggregator and value_counts method to
BlockColumnAccessor. Includes implementations for both Arrow and Pandas
backends.

<!-- Thank you for your contribution! Please review
https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before
opening a pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?

<!-- Please give a short summary of the change and the problem this
solves. -->

## Related issue number

<!-- For example: "Closes #1234" -->

## Checks

- [ ] I've signed off every commit(by using the -s flag, i.e., `git
commit -s`) in this PR.
- [ ] I've run `scripts/format.sh` to lint the changes in this PR.
- [ ] I've included any doc changes needed for
https://docs.ray.io/en/master/.
- [ ] I've added any new APIs to the API Reference. For example, if I
added a
method in Tune, I've added it in `doc/source/tune/api/` under the
           corresponding `.rst` file.
- [ ] I've made sure the tests are passing. Note that there might be a
few flaky tests, see the recent failures at https://flakey-tests.ray.io/
- Testing Strategy
   - [ ] Unit tests
   - [ ] Release tests
   - [ ] This PR is not tested :(

---------

Signed-off-by: cem <[email protected]>
Signed-off-by: cem-anyscale <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Kamil Kaczmarek <[email protected]>
…ging with Timer context manager

Signed-off-by: Kamil Kaczmarek <[email protected]>
… only once." (#57917)

This PR fixes the Ray check failure
RayEventRecorder::StartExportingEvents() should be called only once..
The failure can occur in the following scenario:
- The metric_agent_client successfully establishes a connection with the
dashboard agent. In this case, RayEventRecorder::StartExportingEvents is
correctly invoked to start sending events.
- At the same time, the metric_agent_client exceeds its maximum number
of connection retries. In this case,
RayEventRecorder::StartExportingEvents is invoked again incorrectly,
causing duplicate attempts to start exporting events.

This PR introduces two fixes:
- In metric_agent_client, the connection success and retry logic are now
synchronized (previously they ran asynchronously, allowing both paths to
trigger).
- Do not call StartExportingEvents if the connection cannot be
established.

Test:
- CI

---------

Signed-off-by: Cuong Nguyen <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
## Description

Ray data can't serialize zero (byte) length numpy arrays:

```python3
import numpy as np
import ray.data

array = np.empty((2, 0), dtype=np.int8)

ds = ray.data.from_items([{"array": array}])

for batch in ds.iter_batches(batch_size=1):
     print(batch)
```

What I expect to see:

```
{'array': array([], shape=(1, 2, 0), dtype=int8)}
```

What I see:

```
/Users/chris.ohara/Downloads/.venv/lib/python3.12/site-packages/ray/air/util/tensor_extensions/arrow.py:736: RuntimeWarning: invalid value encountered in scalar divide
  offsets = np.arange(
2025-10-17 17:18:09,499 WARNING arrow.py:189 -- Failed to convert column 'array' into pyarrow array due to: Error converting data to Arrow: column: 'array', shape: (1, 2, 0), dtype: int8, data: []; falling back to serialize as pickled python objects
Traceback (most recent call last):
  File "/Users/chris.ohara/Downloads/.venv/lib/python3.12/site-packages/ray/air/util/tensor_extensions/arrow.py", line 672, in from_numpy
    return cls._from_numpy(arr)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris.ohara/Downloads/.venv/lib/python3.12/site-packages/ray/air/util/tensor_extensions/arrow.py", line 736, in _from_numpy
    offsets = np.arange(
              ^^^^^^^^^^
ValueError: arange: cannot compute length

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/chris.ohara/Downloads/.venv/lib/python3.12/site-packages/ray/air/util/tensor_extensions/arrow.py", line 141, in convert_to_pyarrow_array
    return ArrowTensorArray.from_numpy(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris.ohara/Downloads/.venv/lib/python3.12/site-packages/ray/air/util/tensor_extensions/arrow.py", line 678, in from_numpy
    raise ArrowConversionError(data_str) from e
ray.air.util.tensor_extensions.arrow.ArrowConversionError: Error converting data to Arrow: column: 'array', shape: (1, 2, 0), dtype: int8, data: []
2025-10-17 17:18:09,789 INFO logging.py:293 -- Registered dataset logger for dataset dataset_0_0
2025-10-17 17:18:09,815 WARNING resource_manager.py:134 -- ⚠️  Ray's object store is configured to use only 33.5% of available memory (2.0GiB out of 6.0GiB total). For optimal Ray Data performance, we recommend setting the object store to at least 50% of available memory. You can do this by setting the 'object_store_memory' parameter when calling ray.init() or by setting the RAY_DEFAULT_OBJECT_STORE_MEMORY_PROPORTION environment variable.
{'array': array([array([], shape=(2, 0), dtype=int8)], dtype=object)}
```

This PR fixes the issue so that zero-length arrays are serialized
correctly, and the shape and dtype is preserved.

## Additional information

This is `ray==2.50.0`.

---------

Signed-off-by: Chris O'Hara <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Kamil Kaczmarek <[email protected]>
use awscli directly; stop installing extra dependencies

Signed-off-by: Lonnie Liu <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
## Description
Found this while reading the docs. Not sure what this "Note that" is
referring to or why it is there.

Signed-off-by: Max van Dijck <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
it should not run on macos intel silicon anymore

Signed-off-by: Lonnie Liu <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
@kamil-kaczmarek kamil-kaczmarek force-pushed the kk/rllib-prometheus-metrics branch from f71c2ae to 88f6e3f Compare October 20, 2025 22:41
@kamil-kaczmarek kamil-kaczmarek requested review from a team as code owners October 20, 2025 22:41
@kamil-kaczmarek kamil-kaczmarek removed request for a team October 20, 2025 22:43
Copy link
Contributor

@ArturNiederfahrenhorst ArturNiederfahrenhorst left a comment

Choose a reason for hiding this comment

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

stamp

Signed-off-by: Kamil Kaczmarek <[email protected]>
cursor[bot]

This comment was marked as outdated.

@pcmoritz pcmoritz merged commit 9d279f2 into master Oct 21, 2025
6 checks passed
@pcmoritz pcmoritz deleted the kk/rllib-prometheus-metrics branch October 21, 2025 03:23
xinyuangui2 pushed a commit to xinyuangui2/ray that referenced this pull request Oct 22, 2025
…project#57932)

## Description
This PR add prometheus metrics to the selected RLlib components.

---------

Signed-off-by: joshlee <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
Signed-off-by: kevin <[email protected]>
Signed-off-by: cem <[email protected]>
Signed-off-by: cem-anyscale <[email protected]>
Signed-off-by: Cuong Nguyen <[email protected]>
Signed-off-by: Chris O'Hara <[email protected]>
Signed-off-by: Lonnie Liu <[email protected]>
Signed-off-by: Max van Dijck <[email protected]>
Signed-off-by: Seiji Eicher <[email protected]>
Co-authored-by: Joshua Lee <[email protected]>
Co-authored-by: Kevin H. Luu <[email protected]>
Co-authored-by: cem-anyscale <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Cuong Nguyen <[email protected]>
Co-authored-by: Chris O'Hara <[email protected]>
Co-authored-by: Lonnie Liu <[email protected]>
Co-authored-by: Max van Dijck <[email protected]>
Co-authored-by: Seiji Eicher <[email protected]>
Signed-off-by: xgui <[email protected]>
elliot-barn pushed a commit that referenced this pull request Oct 23, 2025
## Description
This PR add prometheus metrics to the selected RLlib components.

---------

Signed-off-by: joshlee <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
Signed-off-by: kevin <[email protected]>
Signed-off-by: cem <[email protected]>
Signed-off-by: cem-anyscale <[email protected]>
Signed-off-by: Cuong Nguyen <[email protected]>
Signed-off-by: Chris O'Hara <[email protected]>
Signed-off-by: Lonnie Liu <[email protected]>
Signed-off-by: Max van Dijck <[email protected]>
Signed-off-by: Seiji Eicher <[email protected]>
Co-authored-by: Joshua Lee <[email protected]>
Co-authored-by: Kevin H. Luu <[email protected]>
Co-authored-by: cem-anyscale <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Cuong Nguyen <[email protected]>
Co-authored-by: Chris O'Hara <[email protected]>
Co-authored-by: Lonnie Liu <[email protected]>
Co-authored-by: Max van Dijck <[email protected]>
Co-authored-by: Seiji Eicher <[email protected]>
Signed-off-by: elliot-barn <[email protected]>
landscapepainter pushed a commit to landscapepainter/ray that referenced this pull request Nov 17, 2025
…project#57932)

## Description
This PR add prometheus metrics to the selected RLlib components.

---------

Signed-off-by: joshlee <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
Signed-off-by: kevin <[email protected]>
Signed-off-by: cem <[email protected]>
Signed-off-by: cem-anyscale <[email protected]>
Signed-off-by: Cuong Nguyen <[email protected]>
Signed-off-by: Chris O'Hara <[email protected]>
Signed-off-by: Lonnie Liu <[email protected]>
Signed-off-by: Max van Dijck <[email protected]>
Signed-off-by: Seiji Eicher <[email protected]>
Co-authored-by: Joshua Lee <[email protected]>
Co-authored-by: Kevin H. Luu <[email protected]>
Co-authored-by: cem-anyscale <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Cuong Nguyen <[email protected]>
Co-authored-by: Chris O'Hara <[email protected]>
Co-authored-by: Lonnie Liu <[email protected]>
Co-authored-by: Max van Dijck <[email protected]>
Co-authored-by: Seiji Eicher <[email protected]>
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Nov 19, 2025
…project#57932)

## Description
This PR add prometheus metrics to the selected RLlib components.

---------

Signed-off-by: joshlee <[email protected]>
Signed-off-by: Kamil Kaczmarek <[email protected]>
Signed-off-by: kevin <[email protected]>
Signed-off-by: cem <[email protected]>
Signed-off-by: cem-anyscale <[email protected]>
Signed-off-by: Cuong Nguyen <[email protected]>
Signed-off-by: Chris O'Hara <[email protected]>
Signed-off-by: Lonnie Liu <[email protected]>
Signed-off-by: Max van Dijck <[email protected]>
Signed-off-by: Seiji Eicher <[email protected]>
Co-authored-by: Joshua Lee <[email protected]>
Co-authored-by: Kevin H. Luu <[email protected]>
Co-authored-by: cem-anyscale <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Cuong Nguyen <[email protected]>
Co-authored-by: Chris O'Hara <[email protected]>
Co-authored-by: Lonnie Liu <[email protected]>
Co-authored-by: Max van Dijck <[email protected]>
Co-authored-by: Seiji Eicher <[email protected]>
Signed-off-by: Aydin Abiar <[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 release-blocker P0 Issue that blocks the release rllib RLlib related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.