chore(metrics): Upgrade to prometheus-client v0.19.0 (#3207)

This commit is contained in:
Max Inden
2023-01-03 20:42:32 +01:00
committed by GitHub
parent 9c96bbb54b
commit 2621528639
15 changed files with 127 additions and 123 deletions

View File

@ -19,12 +19,10 @@
// DEALINGS IN THE SOFTWARE.
use crate::protocol_stack;
use prometheus_client::encoding::text::Encode;
use prometheus_client::metrics::{
counter::Counter,
family::Family,
histogram::{exponential_buckets, Histogram},
};
use prometheus_client::encoding::{EncodeLabelSet, EncodeLabelValue};
use prometheus_client::metrics::counter::Counter;
use prometheus_client::metrics::family::Family;
use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
use prometheus_client::registry::Registry;
pub struct Metrics {
@ -54,77 +52,77 @@ impl Metrics {
sub_registry.register(
"connections_incoming",
"Number of incoming connections per address stack",
Box::new(connections_incoming.clone()),
connections_incoming.clone(),
);
let connections_incoming_error = Family::default();
sub_registry.register(
"connections_incoming_error",
"Number of incoming connection errors",
Box::new(connections_incoming_error.clone()),
connections_incoming_error.clone(),
);
let new_listen_addr = Family::default();
sub_registry.register(
"new_listen_addr",
"Number of new listen addresses",
Box::new(new_listen_addr.clone()),
new_listen_addr.clone(),
);
let expired_listen_addr = Family::default();
sub_registry.register(
"expired_listen_addr",
"Number of expired listen addresses",
Box::new(expired_listen_addr.clone()),
expired_listen_addr.clone(),
);
let listener_closed = Family::default();
sub_registry.register(
"listener_closed",
"Number of listeners closed",
Box::new(listener_closed.clone()),
listener_closed.clone(),
);
let listener_error = Counter::default();
sub_registry.register(
"listener_error",
"Number of listener errors",
Box::new(listener_error.clone()),
listener_error.clone(),
);
let dial_attempt = Counter::default();
sub_registry.register(
"dial_attempt",
"Number of dial attempts",
Box::new(dial_attempt.clone()),
dial_attempt.clone(),
);
let outgoing_connection_error = Family::default();
sub_registry.register(
"outgoing_connection_error",
"Number outgoing connection errors",
Box::new(outgoing_connection_error.clone()),
outgoing_connection_error.clone(),
);
let connected_to_banned_peer = Family::default();
sub_registry.register(
"connected_to_banned_peer",
"Number of connection attempts to banned peer",
Box::new(connected_to_banned_peer.clone()),
connected_to_banned_peer.clone(),
);
let connections_established = Family::default();
sub_registry.register(
"connections_established",
"Number of connections established",
Box::new(connections_established.clone()),
connections_established.clone(),
);
let connections_closed = Family::default();
sub_registry.register(
"connections_closed",
"Number of connections closed",
Box::new(connections_closed.clone()),
connections_closed.clone(),
);
let connections_establishment_duration = Family::new_with_constructor(
@ -133,7 +131,7 @@ impl Metrics {
sub_registry.register(
"connections_establishment_duration",
"Time it took (locally) to establish connections",
Box::new(connections_establishment_duration.clone()),
connections_establishment_duration.clone(),
);
Self {
@ -293,7 +291,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
}
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
struct ConnectionEstablishedLabels {
role: Role,
protocols: String,
@ -301,18 +299,18 @@ struct ConnectionEstablishedLabels {
type ConnectionEstablishmentDurationLabels = ConnectionEstablishedLabels;
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
struct ConnectionClosedLabels {
role: Role,
protocols: String,
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
struct AddressLabels {
protocols: String,
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
enum Role {
Dialer,
Listener,
@ -327,19 +325,19 @@ impl From<&libp2p_core::ConnectedPoint> for Role {
}
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
struct OutgoingConnectionErrorLabels {
peer: PeerStatus,
error: OutgoingConnectionErrorError,
}
#[derive(Encode, Hash, Clone, Eq, PartialEq, Copy)]
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Copy, Debug)]
enum PeerStatus {
Known,
Unknown,
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
enum OutgoingConnectionErrorError {
Banned,
ConnectionLimit,
@ -354,13 +352,13 @@ enum OutgoingConnectionErrorError {
TransportOther,
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
struct IncomingConnectionErrorLabels {
error: PendingInboundConnectionError,
protocols: String,
}
#[derive(Encode, Hash, Clone, Eq, PartialEq)]
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
enum PendingInboundConnectionError {
WrongPeerId,
TransportErrorMultiaddrNotSupported,