Skip to content

[Metrics] Scope unregister_vllm_metrics() to strictly "vllm:" metrics#42331

Merged
markmc merged 1 commit into
vllm-project:mainfrom
vraiti:feat/precise-unregister
Jun 11, 2026
Merged

[Metrics] Scope unregister_vllm_metrics() to strictly "vllm:" metrics#42331
markmc merged 1 commit into
vllm-project:mainfrom
vraiti:feat/precise-unregister

Conversation

@vraiti

@vraiti vraiti commented May 11, 2026

Copy link
Copy Markdown

Purpose

unregister_vllm_metrics() currently uses "vllm" in collector._name to decide which collectors to remove from the Prometheus registry. This is a substring match that removes every collector whose internal name contains vllm anywhere, including metrics registered by other subsystems or downstream extensions that happen to use vllm in their metric names.

This came up when trying to add Prometheus support to vLLM-Omni: vllm-project/vllm-omni#3362 (comment)

Since the architecture of vLLM-Omni requires that multiple Prometheus collectors be maintained, unregister_vllm_metrics() requires that we use some sort of workaround to preserve our own metrics without messing with the internals of vLLM's metrics. The simpler solution IMO would be for vLLM to just be specific about which metrics it wants to ensure are uninitalized when PrometheusStatLogger is instantiated.

This PR solves this by updating the startwisth string match in unregister_vllm_metrics from "vllm" to "vllm:", meaning that "vllm_omni:"

Changes

  • vllm/v1/metrics/prometheus.py: change startswith("vllm") to startwith("vllm:")

Test Plan

Deploy vLLM-Omni with patched vLLM

Test Result

No errors


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
@vraiti vraiti requested a review from markmc as a code owner May 11, 2026 16:06

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@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 a more granular approach to unregistering vLLM metrics by maintaining an explicit list of metric names in _STAT_LOGGER_METRIC_NAMES. This change ensures that only metrics owned by the PrometheusStatLogger are removed, leaving metrics from other subsystems intact. Additionally, a new test is added to verify that this list stays synchronized with the source code. Review feedback suggests improving the test's regular expression to be more robust against different string formatting and refactoring a line continuation to follow PEP 8 guidelines.

Comment thread tests/v1/metrics/test_metric_name_registry.py Outdated
Comment thread vllm/v1/metrics/prometheus.py Outdated
@mergify mergify Bot added the v1 label May 11, 2026
@vraiti vraiti force-pushed the feat/precise-unregister branch 3 times, most recently from d40efc9 to 42d40a9 Compare May 11, 2026 16:51
@markmc

markmc commented May 12, 2026

Copy link
Copy Markdown
Member

unregister_vllm_metrics() currently uses "vllm" in collector._name to decide which collectors to remove from the Prometheus registry. This is a substring match that removes every collector whose internal name contains vllm anywhere, including metrics registered by other subsystems or downstream extensions that happen to use vllm in their metric names.

This came up when trying to add Prometheus support to vLLM-Omni: vllm-project/vllm-omni#3362 (comment)

How about:

  • Change the check to collector._name.startswith("vllm:")
  • Change vllm:omni_ to vllm_omni:
@vraiti

vraiti commented May 12, 2026

Copy link
Copy Markdown
Author

How about:

  • Change the check to collector._name.startswith("vllm:")
  • Change vllm:omni_ to vllm_omni:

@wuhang2014 what do you think?

@wuhang2014

Copy link
Copy Markdown
Contributor

How about:

  • Change the check to collector._name.startswith("vllm:")
  • Change vllm:omni_ to vllm_omni:

@wuhang2014 what do you think?

One concern is that for models like qwen3-omni, which have two LLM stages, this would initialize the collector twice.

@vraiti

vraiti commented May 12, 2026

Copy link
Copy Markdown
Author

One concern is that for models like qwen3-omni, which have two LLM stages, this would initialize the collector twice.

Under vLLM-Omni's current architecture and the design of vLLM-Omni/#3362, it would not. The collector is initialized once in the orchestrator and collects all vLLM metrics from any LLM-type stages.

@wuhang2014

Copy link
Copy Markdown
Contributor

One concern is that for models like qwen3-omni, which have two LLM stages, this would initialize the collector twice.

Under vLLM-Omni's current architecture and the design of vLLM-Omni/#3362, it would not. The collector is initialized once in the orchestrator and collects all vLLM metrics from any LLM-type stages.

I'm good with it then.

@vraiti vraiti force-pushed the feat/precise-unregister branch from 42d40a9 to cb01baa Compare May 13, 2026 18:32
@vraiti

vraiti commented May 13, 2026

Copy link
Copy Markdown
Author

@markmc we should be good with just a simple startswith("vllm:") :)

@markmc markmc added the ready ONLY add when PR is ready to merge/full CI is needed label May 13, 2026
@markmc markmc changed the title Scope unregister_vllm_metrics to PrometheusStatLogger-owned metrics May 13, 2026
@markmc markmc enabled auto-merge (squash) May 13, 2026 19:57
@markmc markmc moved this from Backlog to Ready in Prometheus Metrics May 13, 2026
@mergify

mergify Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Hi @vraiti, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Tip

Is mypy failing?
mypy is run differently in CI. If the failure is related to this check, please use the following command to run it locally:
# For mypy (substitute "3.10" with the failing version if needed)
pre-commit run --hook-stage manual mypy-3.10
auto-merge was automatically disabled May 14, 2026 14:51

Head branch was pushed to by a user without write access

@vraiti vraiti force-pushed the feat/precise-unregister branch from cb01baa to e8116ba Compare May 14, 2026 14:51
@vraiti

vraiti commented May 15, 2026

Copy link
Copy Markdown
Author

@markmc The CI seems to be failing just due to the fact that the runners are not being allocated GPUs. Is there a way to get around this?

@vraiti vraiti changed the title [Metrics] Scope unregister_vllm_metrics() to PrometheusStatLogger-owned metrics Jun 6, 2026
@mergify

mergify Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Hi @vraiti, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: vraiti <vraiti@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
@markmc markmc force-pushed the feat/precise-unregister branch from c2a49f3 to 9fde5c0 Compare June 11, 2026 13:56
@markmc markmc enabled auto-merge (squash) June 11, 2026 13:58
@markmc markmc merged commit 79f8c5b into vllm-project:main Jun 11, 2026
64 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Done in Prometheus Metrics Jun 11, 2026
Saddss pushed a commit to Saddss/vllm that referenced this pull request Jun 14, 2026
…vllm-project#42331)

`unregister_vllm_metrics()` currently uses "vllm" in `collector._name` to decide
which collectors to remove from the Prometheus registry, removing every even
metrics registered by other subsystems or downstream extensions like "vllm_omni:"

Signed-off-by: vraiti <vraiti@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
divineearthly pushed a commit to divineearthly/vllm that referenced this pull request Jun 19, 2026
…vllm-project#42331)

`unregister_vllm_metrics()` currently uses "vllm" in `collector._name` to decide
which collectors to remove from the Prometheus registry, removing every even
metrics registered by other subsystems or downstream extensions like "vllm_omni:"

Signed-off-by: vraiti <vraiti@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: divineearthly <divineearthly@gmail.com>
tunglinwood pushed a commit to tunglinwood/vllm that referenced this pull request Jun 22, 2026
…vllm-project#42331)

`unregister_vllm_metrics()` currently uses "vllm" in `collector._name` to decide
which collectors to remove from the Prometheus registry, removing every even
metrics registered by other subsystems or downstream extensions like "vllm_omni:"

Signed-off-by: vraiti <vraiti@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
nkzhenhua pushed a commit to nkzhenhua/vllm that referenced this pull request Jun 24, 2026
…vllm-project#42331)

`unregister_vllm_metrics()` currently uses "vllm" in `collector._name` to decide
which collectors to remove from the Prometheus registry, removing every even
metrics registered by other subsystems or downstream extensions like "vllm_omni:"

Signed-off-by: vraiti <vraiti@redhat.com>
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed v1

3 participants