Skip to content

Conversation

@mladjan-gadzic
Copy link

@mladjan-gadzic mladjan-gadzic commented Dec 15, 2025

Purpose

Implemented feature #30394

Test Plan

Added tests.

Test Result

All metrics test passes.


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.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: Mladjan Gadzic <[email protected]>
@mergify
Copy link

mergify bot commented Dec 15, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @mladjan-gadzic.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

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 a well-designed abstraction layer for metrics, which will make it easier to support different backends like Prometheus and OpenTelemetry in the future. The refactoring of existing metric collection points to use this new abstraction is thorough. I've found one critical issue related to a leaky abstraction that needs to be addressed to ensure backend-agnostic behavior.

self.labelname_max_lora: self.max_lora,
}
self.gauge_lora_info.labels(**lora_info_labels).set_to_current_time()
self.gauge_lora_info.labels(**lora_info_labels).set_to_current_time() # type: ignore[attr-defined]
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The method set_to_current_time() is specific to the prometheus-client and is not part of the AbstractGauge interface. Using it breaks the abstraction layer you've introduced, and it will cause a runtime error if a different metrics backend (like the prototype OTEL one) is used.

To fix this and adhere to the abstraction, you should use the set() method from the AbstractGauge interface with the current time. The type: ignore is still necessary due to how labels() is typed in the base class, which is a separate typing issue.

Suggested change
self.gauge_lora_info.labels(**lora_info_labels).set_to_current_time() # type: ignore[attr-defined]
self.gauge_lora_info.labels(**lora_info_labels).set(time.time()) # type: ignore[attr-defined]

Copy link
Contributor

@bbartels bbartels left a comment

Choose a reason for hiding this comment

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

A couple follow up clean-up tasks would be good, ideally any publisher of metrics isn't aware of which backend is being exported to, so references to prometheus could be cleaned up in various places (assuming it doesn't break public API surface).

Worth updating docs (if there are any) to reflect these changes so developers are aware of the changes of how to register metrics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants