-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#### Motivation This PR accomplishes two things: - Upgrades the `metrics` crate to the latest version, which causes API breaking changes - Duplicates all counter metrics to include `{metric_name}_total` to align with the prometheus metrics exported by vLLM #### Modifications This refactors all usages of the `metrics` crate into a single file, so that changes to how it's used can be made in one place. This lets us easily duplicate all the counter metrics. #### Result No existing behavior should change, only new `*_total` counters should be added to the /metrics endpoint. --------- Signed-off-by: Joe Runde <[email protected]>
- Loading branch information
Showing
9 changed files
with
559 additions
and
376 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Small helpers for using the metrics crate. | ||
// This aims to collect all usages of the metrics crate so that future api-breaking changes can be handled in one place. | ||
|
||
|
||
// These counter helper methods will actually increment a second counter with `_total` appended to the name. | ||
// This is for compatibility with other runtimes that use prometheus directly, which is very | ||
// opinionated that all counters should end with the suffix _total. | ||
// Cite: https://prometheus.github.io/client_python/instrumenting/counter/ | ||
|
||
pub fn increment_counter(name: &'static str, value: u64) { | ||
metrics::counter!(name).increment(value); | ||
metrics::counter!(format!("{name}_total")).increment(value); | ||
} | ||
|
||
|
||
pub fn increment_labeled_counter(name: &'static str, labels: &[(&'static str, &'static str)], value: u64) { | ||
metrics::counter!(name, labels).increment(value); | ||
metrics::counter!(format!("{name}_total"), labels).increment(value); | ||
} | ||
|
||
|
||
pub fn set_gauge(name: &'static str, value: f64) { | ||
metrics::gauge!(name).set(value); | ||
} | ||
|
||
|
||
pub fn observe_histogram(name: &'static str, value: f64) { | ||
metrics::histogram!(name).record(value); | ||
} | ||
|
||
|
||
pub fn observe_labeled_histogram(name: &'static str, labels: &[(&'static str, &'static str)], value: f64) { | ||
metrics::histogram!(name, labels).record(value); | ||
} |
Oops, something went wrong.