Repository navigation
[core][gcs] Export GCS storage operation metrics on the Redis backend - #66882
Conversation
There was a problem hiding this comment.
Code Review
This pull request enables storage operation metrics (count and latency) for the external Redis backend by conditionally wrapping the Redis store client in ObservableStoreClient using a new MaybeObserve helper, controlled by the gcs_redis_storage_metrics_enabled configuration. To facilitate this, ObservableStoreClient and StoreClientInternalKV have been updated to use std::shared_ptr instead of std::unique_ptr. The review feedback recommends adding a RAY_CHECK in the StoreClientInternalKV constructor to defensively guard against null pointer dereferences.
4a061d7 to
6375687
Compare
|
The changes LGTM. can you please shorten/clean-up the redundancies in the comments? And also, lets update the docs too. @rueian, I am not sure if we should add in a config for this change, or let it go without a config flag since in-memory and rocksDB store already have the behaviour. Can you please help here? |
…ncy metrics (#65583) ## Description `gcs_storage_operation_count` and `gcs_storage_operation_latency_ms` are labeled by `Operation` only, so a slow `GetAll` on the actor table can't be told apart from one on the job table without correlating logs. `ObservableStoreClient` already receives a `table_name` on every call. This PR: - records it as a bounded `TableName` label on both metrics, for `Put`, `Get`, `GetAll`, `MultiGet`, `Delete`, `BatchDelete`, `GetKeys` and `Exists`; - instruments `GetNextJobID`, the one storage operation the wrapper used to skip; - measures latency on the monotonic clock instead of wall time; - documents both metrics in `system-metrics.md`. Exporting these metrics on the external-Redis backend, where they don't exist today, was split out of this PR at review into #66882. ## Related issues Closes #65582. ## Additional information ### Label cardinality `StoreClient` accepts any string as a table name (the shared test base passes `"test_table"`), so the label is bounded explicitly: `NormalizeTableNameLabel` keeps names from the `rpc::TablePrefix` enum and maps anything else to `OTHER`. In practice the GCS produces seven values: `JOB`, `ACTOR`, `ACTOR_TASK_SPEC`, `PLACEMENT_GROUP`, `NODE`, `WORKERS` and `KV`. The hard upper bound is 161 `Operation` × `TableName` combinations per GCS process (8 table operations × 20 values, plus `GetNextJobID` × `JobCounter`), independent of cluster size or actor count. No user-controlled string reaches a label: the internal KV puts the user's namespace in the key (`MakeKey` in `store_client_kv.cc`), not in the table name. `NoUserDataInLabels` covers this. ### `GetNextJobID` It addresses a counter key rather than a table, so it reports the `JobCounter` sentinel. It can't simply leave `TableName` unset: `tag_keys` is the tag allowlist on both metric stacks, and a declared tag that a call site doesn't record is exported as an empty string, so it would show up as `TableName=""`. ### Latency clock Latency used to be the difference of two `NowUnixNanos()` readings, which is wall time, so an NTP step could record a negative or inflated value. Every recording site is rewritten here anyway, so they now use `SteadyNow()`, which `ClockInterface` documents as the clock for durations. ### Compatibility / release note This changes series identity: each `Operation` now has up to seven series instead of one, and `GetNextJobID` is a new `Operation` value. Label matchers are unaffected. A dashboard or alert that assumed one series per operation can aggregate the new label away: ```promql sum without (TableName) (rate(ray_gcs_storage_operation_count_total[5m])) ``` Use `without (TableName)` rather than `by (Operation)`, because `by` also drops `SessionName`, `Component` and the other global labels. Aggregations sensitive to series count (`avg`, `max`, `count`) still change. ### Not a duplicate Searching open PRs for `"TableName gcs_storage_operation"`, `"observable store client"`, `"gcs_storage_operation redis"` and `"MaybeObserve"` finds no other PR labeling these metrics. #66847 edits the same `Record` call sites to move recording onto a separate io_context. It changes where recording runs, not what is recorded, so the two compose and whichever lands second rebases. ### Testing ```bash bazel test //src/ray/gcs/store_client/tests:table_name_label_test \ //src/ray/gcs/store_client/tests:observable_store_client_test \ //src/ray/gcs/store_client/tests:in_memory_store_client_test # Executed 3 out of 3 tests: 3 tests pass. pre-commit run --from-ref upstream/master --to-ref HEAD # All hooks passed. ``` AI assistance (Claude Code) was used to prepare this change. I reviewed every changed line and ran the tests above locally. --------- Signed-off-by: zzchun <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Douglas Strodtman <[email protected]>
RedisStoreClient is the only StoreClient that GcsServer never wraps in ObservableStoreClient, so gcs_storage_operation_count and gcs_storage_operation_latency_ms are not exported at all when the GCS uses external Redis. Route both REDIS_PERSIST construction sites (cluster tables and internal KV) through a new gcs::MaybeObserve helper, gated by gcs_redis_storage_metrics_enabled (default true) so the new Record calls can be rolled back. ObservableStoreClient and StoreClientInternalKV now hold their delegate as a shared_ptr, because GcsServer keeps a concrete RedisStoreClient pointer for the periodic health check; health-check PINGs keep bypassing the wrapper. Split out of ray-project#65583 at review. Signed-off-by: zzchun <[email protected]>
…trics flag Address review feedback on ray-project#66882: - Shorten the gcs_redis_storage_metrics_enabled comment and drop the description of pre-change behavior. - Remove the duplicated explanation from MaybeObserve, the ObservableStoreClient constructor, GcsServer, StoreClientInternalKV and the test fixtures. - system-metrics.md: the storage operation metrics are now exported on every backend; document RAY_gcs_redis_storage_metrics_enabled and how the count differs from ray_gcs_redis_command_count_total. - RedisObservableGcsTableStorageTest also asserts TableName=JOB. Signed-off-by: zzchun <[email protected]>
6375687 to
d4c5402
Compare
|
@karticam Thanks for the review! Addressed in d4c5402:
Tests run locally after the rebase and fixes: The full On whether to keep the flag: happy to go either way, depending on what @rueian thinks. It's there so the extra per-operation metric recording on the Redis path can be turned off without a redeploy. If it isn't worth having, removing it is a small change: drop |
…docs - MaybeObserveTest writes to the JOB table and asserts TableName=JOB, matching RedisObservableGcsTableStorageTest. - system-metrics.md: shorten the note on the Redis backend. Signed-off-by: zzchun <[email protected]>
The KV store client is never shared, so InitKVManager builds the Redis client as a unique_ptr and wraps it in ObservableStoreClient only when gcs_redis_storage_metrics_enabled is set. StoreClientInternalKV is back to taking and holding a unique_ptr, unchanged from master. MaybeObserve stays on the table storage path, where the health check shares ownership of the RedisStoreClient. Signed-off-by: zzchun <[email protected]>
Description
gcs_storage_operation_countandgcs_storage_operation_latency_msare exported by the in-memory and RocksDB GCS storage backends, but not at all on the external-Redis backend:RedisStoreClientis the onlyStoreClientthatGcsServernever wraps inObservableStoreClient. Dashboards built on these metrics therefore go blank on Redis-backed clusters.This PR routes both
REDIS_PERSISTconstruction sites inGcsServer(cluster tables and internal KV) through a smallgcs::MaybeObservehelper, gated by a newgcs_redis_storage_metrics_enabledconfig (defaulttrue).Related issues
Split out of #65583 at review. That PR adds a
TableNamelabel to the same two metrics; this one makes them exist on Redis. The two are independent and can land in either order.Additional information
Kill switch
Redis is the one backend that gains
Recordcalls where it had none, so it gets a rollback switch:RAY_gcs_redis_storage_metrics_enabled=falserestores the previous behavior. The in-memory and RocksDB backends have always been wrapped and are not gated.Ownership
ObservableStoreClientnow takes its delegate as ashared_ptrinstead of aunique_ptr.AsyncCheckHealthis declared onRedisStoreClientand not on theStoreClientinterface, soGcsServerkeeps a concrete pointer for the periodic health check while handing the same client to the wrapper.StoreClientInternalKVtakes ashared_ptrtoo, because it now consumesMaybeObserve's result. Existing construction sites passunique_ptrrvalues, which convert implicitly, so none of them change.Health-check
PINGs keep bypassing the wrapper: a probe is not a storage operation and should not appear ingcs_storage_operation_count.Compatibility
Purely additive: on Redis, series that did not exist begin to exist. No existing series on any backend changes.
Not a duplicate
This is the Redis half of #65583, split out at the reviewer's request; #65583 no longer contains it. Searching open PRs for
"observable store client","gcs_storage_operation redis"and"MaybeObserve"finds no other PR doing this. #66847 adds ametric_contextparameter to theObservableStoreClientconstructor; whichever lands second threads it throughMaybeObserve.Testing
The new tests match on the
Operationtag only, so they keep passing whether or not #65583'sTableNamelabel lands first.