[Rust Frontend][Metrics] Export vllm:lora_requests_info from frontend (#45030)

Signed-off-by: Will Eaton <weaton@redhat.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Will Eaton
2026-06-11 06:45:03 -07:00
committed by GitHub
co-authored by Bugen Zhao mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent ebc6ef971a
commit cc640ee8bc
8 changed files with 383 additions and 36 deletions
+1
View File
@@ -5,6 +5,7 @@ edition.workspace = true
license.workspace = true
[dependencies]
itertools.workspace = true
prometheus-client.workspace = true
[lints]
+33 -1
View File
@@ -1,4 +1,7 @@
use prometheus_client::encoding::EncodeLabelSet;
use std::collections::BTreeSet;
use itertools::Itertools as _;
use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue, LabelValueEncoder};
use prometheus_client::metrics::family::Family;
use prometheus_client::metrics::histogram::Histogram;
use prometheus_client::registry::Registry;
@@ -42,6 +45,23 @@ pub struct WaitingReasonLabels {
pub reason: &'static str,
}
/// Adapter names encoded as a deterministic comma-joined Prometheus label value.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct LoraAdapterNames(pub BTreeSet<String>);
impl EncodeLabelValue for LoraAdapterNames {
fn encode(&self, encoder: &mut LabelValueEncoder) -> Result<(), std::fmt::Error> {
EncodeLabelValue::encode(&self.0.iter().join(","), encoder)
}
}
/// Labels for `vllm:lora_requests_info`.
#[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)]
pub struct LoraInfoLabels {
pub running_lora_adapters: LoraAdapterNames,
pub waiting_lora_adapters: LoraAdapterNames,
}
/// Scheduler/batch-scoped Prometheus families exported from `SchedulerStats`.
pub struct SchedulerMetrics {
// Scheduler state gauges.
@@ -50,6 +70,10 @@ pub struct SchedulerMetrics {
pub scheduler_waiting_by_reason: Family<WaitingReasonLabels, U64Gauge>,
pub kv_cache_usage: Family<EngineLabels, F64Gauge>,
/// `vllm:lora_requests_info`. Value is the emit-time unix timestamp in
/// seconds.
pub lora_info: Family<LoraInfoLabels, F64Gauge>,
// Prefix-cache counters, including the connector-backed external cache path.
pub prefix_cache_queries: Family<EngineLabels, U64Counter>,
pub prefix_cache_hits: Family<EngineLabels, U64Counter>,
@@ -109,6 +133,13 @@ impl SchedulerMetrics {
kv_cache_usage.clone(),
);
let lora_info = Family::default();
registry.register(
"vllm:lora_requests_info",
"Running stats on lora requests.",
lora_info.clone(),
);
// Prefix-cache counters, including the connector-backed external cache path.
let prefix_cache_queries = Family::default();
registry.register(
@@ -219,6 +250,7 @@ impl SchedulerMetrics {
scheduler_waiting,
scheduler_waiting_by_reason,
kv_cache_usage,
lora_info,
prefix_cache_queries,
prefix_cache_hits,
external_prefix_cache_queries,