improve libp2p connected peer metrics (#4870)

* improve libp2p connected peer metrics

* separate discv5 port from libp2p for NAT open

* use metric family for DISCOVERY_BYTES

* Merge branch 'unstable' of https://github.com/sigp/lighthouse into improve-metrics
This commit is contained in:
João Oliveira
2024-02-08 02:40:54 +00:00
committed by GitHub
parent 0b59d10ab6
commit 0c3fef59b3
7 changed files with 65 additions and 100 deletions

View File

@@ -244,6 +244,16 @@ pub fn inc_counter_vec(int_counter_vec: &Result<IntCounterVec>, name: &[&str]) {
}
}
/// Sets the `int_counter_vec` with the given `name` to the `amount`,
/// should only be called with `ammount`s equal or above the current value
/// as per Prometheus spec, the `counter` type should only go up.
pub fn set_counter_vec_by(int_counter_vec: &Result<IntCounterVec>, name: &[&str], amount: u64) {
if let Some(counter) = get_int_counter(int_counter_vec, name) {
counter.reset();
counter.inc_by(amount);
}
}
pub fn inc_counter_vec_by(int_counter_vec: &Result<IntCounterVec>, name: &[&str], amount: u64) {
if let Some(counter) = get_int_counter(int_counter_vec, name) {
counter.inc_by(amount);