[core][telemetry] Reduce cardinality of Serve metrics to node level - #65053
Draft
eicherseiji wants to merge 5 commits into
Draft
[core][telemetry] Reduce cardinality of Serve metrics to node level#65053eicherseiji wants to merge 5 commits into
eicherseiji wants to merge 5 commits into
Conversation
At the recommended and low cardinality levels, the OpenTelemetry export now drops WorkerId and ReplicaId from any metric that carries a ReplicaId tag and aggregates the collapsed per-replica series to the node level. ReplicaId presence scopes the reduction to Serve metrics, including vLLM engine metrics, so tasks, actors, and unrelated user metrics keep their current behavior. Gauges sum by default so additive per-replica gauges (running, waiting) collapse to a correct node total. vllm:kv_cache_usage_perc is a 0..1 ratio and uses the mean instead. The OpenCensus export path is not covered; it is not the default backend. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
Gauges aggregate by sum generically. Ray core no longer names a metric from another project. A ratio gauge overcounts under sum and should be aggregated at the query layer until the metric owner can declare its aggregation. Move the unit tests into test_metric_cardinality.py so they run under the existing Bazel target instead of an untargeted new file. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
Align with ray-project#63642: keep the tags by default, reduce only on an explicit opt-in. Serve metrics now drop WorkerId and ReplicaId at the low level only. The default level recommended leaves Serve metrics unchanged. tasks and actors keep their existing behavior. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
…evel Unify the Serve controller metrics knob with the core cardinality level. RAY_SERVE_CONTROLLER_METRICS_INCLUDE_HIGH_CARDINALITY_TAGS now takes its default from RAY_metric_cardinality_level: the low level drops the high-cardinality controller tags, matching how low reduces other Serve metrics. Setting the env var explicitly still overrides the level. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
RAY_metric_cardinality_level is now the documented control for dropping high-cardinality tags from Serve controller metrics: the low level drops them. RAY_SERVE_CONTROLLER_METRICS_INCLUDE_HIGH_CARDINALITY_TAGS becomes a deprecated alias. When set explicitly it still wins, and it now emits a deprecation warning pointing to the level. Adds a unit test for the resolution and updates the monitoring doc. Signed-off-by: Seiji Eicher <seiji@anyscale.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make Serve and vLLM metrics honor Ray's metric cardinality reduction, with
RAY_metric_cardinality_levelas the single control. Atlow:WorkerIdandReplicaIdfrom any metric carrying aReplicaIdtag, and aggregates the collapsed per-replica series to the node level.handle/replicatags (the behavior from Added RAY_SERVE_CONTROLLER_METRICS_INCLUDE_HIGH_CARDINALITY_TAGS to c… #63642), now driven by the same level.Why
tasksandactors. Every Serve and vLLM metric keptWorkerId/ReplicaIdat every level. Those labels are 1:1 per replica, so the series count grew with replicas and never reduced.Posture
Keep tags by default; reduce only at
low. Matches #63642's opt-out posture.legacy,recommended(default): tags kept.low:WorkerId+ReplicaIddropped from Serve/vLLM metrics; controllerhandle/replicadropped.tasks/actorskeep their existing per-level behavior.Unifying #63642
RAY_metric_cardinality_levelis now the canonical, documented control.RAY_SERVE_CONTROLLER_METRICS_INCLUDE_HIGH_CARDINALITY_TAGSbecomes a deprecated alias: its default is derived from the level, and when set explicitly it still wins (backwards compatible) but emits a deprecation warning pointing to the level. Full removal is left to a coordinated follow-up with a deprecation cycle.Scope
ReplicaIdpresence scopes the reducer to Serve/vLLM metrics; other user metrics are untouched. The controller change is limited to the four metrics #63642 already gated.Aggregation
Gauges sum by default (correct for additive gauges like
num_requests_running); counters sum; histograms merge buckets. Ray core does not name any metric from another project.Changes
metric_cardinality.py:get_high_cardinality_labels_to_droptakes the series tag keys; atlow, dropsWorkerId+ReplicaIdforReplicaId-bearing metrics. Gauges default to sum.open_telemetry_metric_recorder.py: pass the series tag keys at the gauge/counter callback and both histogram paths.serve/_private/constants.py: derive the controller knob from the level; deprecate the env var (still honored, warns).doc/source/serve/monitoring.md: document the level as canonical; mark the env var deprecated.Known limitations
ReplicaId-bearing (vLLM) series and the controller tags. Does not reduce the larger Ray-internal histogram bulk (ray_grpc_server_*, etc.) orray_serve_*latency buckets, which the tag scoping does not reach. Measured:lowleavesray_grpc_server_req_process_time_ms_bucketat 203 series unchanged. Broadening is a follow-up.vllm:kv_cache_usage_perc); aggregate at the query layer until the metric owner can declare its aggregation.Relationship to #63642
#63642 (merged) drops
handle/replicafrom controller metrics at emit time, on the head node. This PR dropsWorkerId/ReplicaIdfrom replica/vLLM metrics at the reporter agent, and folds #63642's knob under the shared level. Drop location stays different by necessity: the controller aggregates centrally, replica metrics can only be summed at the agent.Tests
Run locally against a per-commit wheel.
Reducer path (
test_metric_cardinality.py):test_serve_metric_cardinality: 3 passed. Originaltest_cardinality_recommended_and_legacy_levels: 9 passed (no regression).Controller unification:
serve/tests/unit/test_metric_cardinality_constants.py: 5 passed (level drives the default; alias overrides; deprecation warning emitted).ray_serve_deployment_replica_healthy.recommendedshows two per-replica series with areplicatag;lowcollapses to one series with noreplicatag and value 2.0 (healthy count); explicit env var restores the tag.AI assistance (Claude Code) was used to write this change.