2021-08-13 22:51:54 +02:00
|
|
|
// Copyright 2021 Protocol Labs.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
use crate::protocol_stack;
|
2023-01-03 20:42:32 +01:00
|
|
|
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};
|
2022-02-03 11:31:41 +01:00
|
|
|
use prometheus_client::registry::Registry;
|
2021-08-13 22:51:54 +02:00
|
|
|
|
|
|
|
pub struct Metrics {
|
2022-11-15 15:45:14 -05:00
|
|
|
connections_incoming: Family<AddressLabels, Counter>,
|
2021-08-13 22:51:54 +02:00
|
|
|
connections_incoming_error: Family<IncomingConnectionErrorLabels, Counter>,
|
|
|
|
|
2021-09-09 15:35:45 +02:00
|
|
|
connections_established: Family<ConnectionEstablishedLabels, Counter>,
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
connections_establishment_duration: Family<ConnectionEstablishmentDurationLabels, Histogram>,
|
2021-09-09 15:35:45 +02:00
|
|
|
connections_closed: Family<ConnectionClosedLabels, Counter>,
|
2021-08-13 22:51:54 +02:00
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
new_listen_addr: Family<AddressLabels, Counter>,
|
|
|
|
expired_listen_addr: Family<AddressLabels, Counter>,
|
2021-08-13 22:51:54 +02:00
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
listener_closed: Family<AddressLabels, Counter>,
|
2021-08-13 22:51:54 +02:00
|
|
|
listener_error: Counter,
|
|
|
|
|
|
|
|
dial_attempt: Counter,
|
2021-10-14 18:05:07 +02:00
|
|
|
outgoing_connection_error: Family<OutgoingConnectionErrorLabels, Counter>,
|
2022-11-15 15:45:14 -05:00
|
|
|
connected_to_banned_peer: Family<AddressLabels, Counter>,
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Metrics {
|
|
|
|
pub fn new(registry: &mut Registry) -> Self {
|
|
|
|
let sub_registry = registry.sub_registry_with_prefix("swarm");
|
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
let connections_incoming = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
|
|
|
"connections_incoming",
|
2022-11-15 15:45:14 -05:00
|
|
|
"Number of incoming connections per address stack",
|
2023-01-03 20:42:32 +01:00
|
|
|
connections_incoming.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let connections_incoming_error = Family::default();
|
|
|
|
sub_registry.register(
|
|
|
|
"connections_incoming_error",
|
|
|
|
"Number of incoming connection errors",
|
2023-01-03 20:42:32 +01:00
|
|
|
connections_incoming_error.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
let new_listen_addr = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
|
|
|
"new_listen_addr",
|
|
|
|
"Number of new listen addresses",
|
2023-01-03 20:42:32 +01:00
|
|
|
new_listen_addr.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
let expired_listen_addr = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
|
|
|
"expired_listen_addr",
|
|
|
|
"Number of expired listen addresses",
|
2023-01-03 20:42:32 +01:00
|
|
|
expired_listen_addr.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
let listener_closed = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
|
|
|
"listener_closed",
|
|
|
|
"Number of listeners closed",
|
2023-01-03 20:42:32 +01:00
|
|
|
listener_closed.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let listener_error = Counter::default();
|
|
|
|
sub_registry.register(
|
|
|
|
"listener_error",
|
|
|
|
"Number of listener errors",
|
2023-01-03 20:42:32 +01:00
|
|
|
listener_error.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let dial_attempt = Counter::default();
|
|
|
|
sub_registry.register(
|
|
|
|
"dial_attempt",
|
|
|
|
"Number of dial attempts",
|
2023-01-03 20:42:32 +01:00
|
|
|
dial_attempt.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
2021-10-14 18:05:07 +02:00
|
|
|
let outgoing_connection_error = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
2021-10-14 18:05:07 +02:00
|
|
|
"outgoing_connection_error",
|
|
|
|
"Number outgoing connection errors",
|
2023-01-03 20:42:32 +01:00
|
|
|
outgoing_connection_error.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
2022-11-15 15:45:14 -05:00
|
|
|
let connected_to_banned_peer = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
|
|
|
"connected_to_banned_peer",
|
|
|
|
"Number of connection attempts to banned peer",
|
2023-01-03 20:42:32 +01:00
|
|
|
connected_to_banned_peer.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
let connections_established = Family::default();
|
|
|
|
sub_registry.register(
|
|
|
|
"connections_established",
|
|
|
|
"Number of connections established",
|
2023-01-03 20:42:32 +01:00
|
|
|
connections_established.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
2021-09-09 15:35:45 +02:00
|
|
|
let connections_closed = Family::default();
|
2021-08-13 22:51:54 +02:00
|
|
|
sub_registry.register(
|
|
|
|
"connections_closed",
|
|
|
|
"Number of connections closed",
|
2023-01-03 20:42:32 +01:00
|
|
|
connections_closed.clone(),
|
2021-08-13 22:51:54 +02:00
|
|
|
);
|
|
|
|
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
let connections_establishment_duration = Family::new_with_constructor(
|
|
|
|
create_connection_establishment_duration_histogram as fn() -> Histogram,
|
|
|
|
);
|
|
|
|
sub_registry.register(
|
|
|
|
"connections_establishment_duration",
|
|
|
|
"Time it took (locally) to establish connections",
|
2023-01-03 20:42:32 +01:00
|
|
|
connections_establishment_duration.clone(),
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
);
|
|
|
|
|
2021-08-13 22:51:54 +02:00
|
|
|
Self {
|
|
|
|
connections_incoming,
|
|
|
|
connections_incoming_error,
|
|
|
|
connections_established,
|
|
|
|
connections_closed,
|
|
|
|
new_listen_addr,
|
|
|
|
expired_listen_addr,
|
|
|
|
listener_closed,
|
|
|
|
listener_error,
|
|
|
|
dial_attempt,
|
2021-10-14 18:05:07 +02:00
|
|
|
outgoing_connection_error,
|
2021-08-13 22:51:54 +02:00
|
|
|
connected_to_banned_peer,
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
connections_establishment_duration,
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-15 09:16:03 +02:00
|
|
|
impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleErr>> for Metrics {
|
2021-08-13 22:51:54 +02:00
|
|
|
fn record(&self, event: &libp2p_swarm::SwarmEvent<TBvEv, THandleErr>) {
|
|
|
|
match event {
|
|
|
|
libp2p_swarm::SwarmEvent::Behaviour(_) => {}
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
libp2p_swarm::SwarmEvent::ConnectionEstablished {
|
|
|
|
endpoint,
|
|
|
|
established_in: time_taken,
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
let labels = ConnectionEstablishedLabels {
|
|
|
|
role: endpoint.into(),
|
|
|
|
protocols: protocol_stack::as_string(endpoint.get_remote_address()),
|
|
|
|
};
|
|
|
|
self.connections_established.get_or_create(&labels).inc();
|
|
|
|
self.connections_establishment_duration
|
|
|
|
.get_or_create(&labels)
|
|
|
|
.observe(time_taken.as_secs_f64());
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2021-09-09 15:35:45 +02:00
|
|
|
libp2p_swarm::SwarmEvent::ConnectionClosed { endpoint, .. } => {
|
2022-07-15 09:16:03 +02:00
|
|
|
self.connections_closed
|
2021-09-09 15:35:45 +02:00
|
|
|
.get_or_create(&ConnectionClosedLabels {
|
|
|
|
role: endpoint.into(),
|
2022-11-15 15:45:14 -05:00
|
|
|
protocols: protocol_stack::as_string(endpoint.get_remote_address()),
|
2021-09-09 15:35:45 +02:00
|
|
|
})
|
|
|
|
.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2022-11-15 15:45:14 -05:00
|
|
|
libp2p_swarm::SwarmEvent::IncomingConnection { send_back_addr, .. } => {
|
|
|
|
self.connections_incoming
|
|
|
|
.get_or_create(&AddressLabels {
|
|
|
|
protocols: protocol_stack::as_string(send_back_addr),
|
|
|
|
})
|
|
|
|
.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2022-11-15 15:45:14 -05:00
|
|
|
libp2p_swarm::SwarmEvent::IncomingConnectionError {
|
|
|
|
error,
|
|
|
|
send_back_addr,
|
|
|
|
..
|
|
|
|
} => {
|
2022-07-15 09:16:03 +02:00
|
|
|
self.connections_incoming_error
|
2021-08-13 22:51:54 +02:00
|
|
|
.get_or_create(&IncomingConnectionErrorLabels {
|
|
|
|
error: error.into(),
|
2022-11-15 15:45:14 -05:00
|
|
|
protocols: protocol_stack::as_string(send_back_addr),
|
2021-08-13 22:51:54 +02:00
|
|
|
})
|
|
|
|
.inc();
|
|
|
|
}
|
2021-10-14 18:05:07 +02:00
|
|
|
libp2p_swarm::SwarmEvent::OutgoingConnectionError { error, peer_id } => {
|
|
|
|
let peer = match peer_id {
|
|
|
|
Some(_) => PeerStatus::Known,
|
|
|
|
None => PeerStatus::Unknown,
|
|
|
|
};
|
|
|
|
|
|
|
|
let record = |error| {
|
2022-07-15 09:16:03 +02:00
|
|
|
self.outgoing_connection_error
|
2021-10-14 18:05:07 +02:00
|
|
|
.get_or_create(&OutgoingConnectionErrorLabels { peer, error })
|
|
|
|
.inc();
|
|
|
|
};
|
|
|
|
|
|
|
|
match error {
|
|
|
|
libp2p_swarm::DialError::Transport(errors) => {
|
|
|
|
for (_multiaddr, error) in errors {
|
|
|
|
match error {
|
|
|
|
libp2p_core::transport::TransportError::MultiaddrNotSupported(
|
|
|
|
_,
|
|
|
|
) => record(
|
|
|
|
OutgoingConnectionErrorError::TransportMultiaddrNotSupported,
|
|
|
|
),
|
|
|
|
libp2p_core::transport::TransportError::Other(_) => {
|
|
|
|
record(OutgoingConnectionErrorError::TransportOther)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
libp2p_swarm::DialError::Banned => record(OutgoingConnectionErrorError::Banned),
|
|
|
|
libp2p_swarm::DialError::ConnectionLimit(_) => {
|
|
|
|
record(OutgoingConnectionErrorError::ConnectionLimit)
|
|
|
|
}
|
2023-01-26 11:20:23 +04:00
|
|
|
libp2p_swarm::DialError::LocalPeerId { .. } => {
|
2021-10-14 18:05:07 +02:00
|
|
|
record(OutgoingConnectionErrorError::LocalPeerId)
|
|
|
|
}
|
|
|
|
libp2p_swarm::DialError::NoAddresses => {
|
|
|
|
record(OutgoingConnectionErrorError::NoAddresses)
|
|
|
|
}
|
|
|
|
libp2p_swarm::DialError::DialPeerConditionFalse(_) => {
|
|
|
|
record(OutgoingConnectionErrorError::DialPeerConditionFalse)
|
|
|
|
}
|
|
|
|
libp2p_swarm::DialError::Aborted => {
|
|
|
|
record(OutgoingConnectionErrorError::Aborted)
|
|
|
|
}
|
2022-01-18 21:21:11 +01:00
|
|
|
libp2p_swarm::DialError::InvalidPeerId { .. } => {
|
2021-10-14 18:05:07 +02:00
|
|
|
record(OutgoingConnectionErrorError::InvalidPeerId)
|
|
|
|
}
|
2022-01-18 21:21:11 +01:00
|
|
|
libp2p_swarm::DialError::WrongPeerId { .. } => {
|
|
|
|
record(OutgoingConnectionErrorError::WrongPeerId)
|
|
|
|
}
|
2021-10-14 18:05:07 +02:00
|
|
|
libp2p_swarm::DialError::ConnectionIo(_) => {
|
|
|
|
record(OutgoingConnectionErrorError::ConnectionIo)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-11-15 15:45:14 -05:00
|
|
|
libp2p_swarm::SwarmEvent::BannedPeer { endpoint, .. } => {
|
|
|
|
self.connected_to_banned_peer
|
|
|
|
.get_or_create(&AddressLabels {
|
|
|
|
protocols: protocol_stack::as_string(endpoint.get_remote_address()),
|
|
|
|
})
|
|
|
|
.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2022-11-15 15:45:14 -05:00
|
|
|
libp2p_swarm::SwarmEvent::NewListenAddr { address, .. } => {
|
|
|
|
self.new_listen_addr
|
|
|
|
.get_or_create(&AddressLabels {
|
|
|
|
protocols: protocol_stack::as_string(address),
|
|
|
|
})
|
|
|
|
.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2022-11-15 15:45:14 -05:00
|
|
|
libp2p_swarm::SwarmEvent::ExpiredListenAddr { address, .. } => {
|
|
|
|
self.expired_listen_addr
|
|
|
|
.get_or_create(&AddressLabels {
|
|
|
|
protocols: protocol_stack::as_string(address),
|
|
|
|
})
|
|
|
|
.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2022-11-15 15:45:14 -05:00
|
|
|
libp2p_swarm::SwarmEvent::ListenerClosed { addresses, .. } => {
|
|
|
|
for address in addresses {
|
|
|
|
self.listener_closed
|
|
|
|
.get_or_create(&AddressLabels {
|
|
|
|
protocols: protocol_stack::as_string(address),
|
|
|
|
})
|
|
|
|
.inc();
|
|
|
|
}
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
libp2p_swarm::SwarmEvent::ListenerError { .. } => {
|
2022-07-15 09:16:03 +02:00
|
|
|
self.listener_error.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
libp2p_swarm::SwarmEvent::Dialing(_) => {
|
2022-07-15 09:16:03 +02:00
|
|
|
self.dial_attempt.inc();
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-09-09 15:35:45 +02:00
|
|
|
struct ConnectionEstablishedLabels {
|
|
|
|
role: Role,
|
2022-11-15 15:45:14 -05:00
|
|
|
protocols: String,
|
2021-09-09 15:35:45 +02:00
|
|
|
}
|
|
|
|
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
type ConnectionEstablishmentDurationLabels = ConnectionEstablishedLabels;
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-09-09 15:35:45 +02:00
|
|
|
struct ConnectionClosedLabels {
|
2021-08-13 22:51:54 +02:00
|
|
|
role: Role,
|
2022-11-15 15:45:14 -05:00
|
|
|
protocols: String,
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
|
2022-11-15 15:45:14 -05:00
|
|
|
struct AddressLabels {
|
|
|
|
protocols: String,
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-08-13 22:51:54 +02:00
|
|
|
enum Role {
|
|
|
|
Dialer,
|
|
|
|
Listener,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<&libp2p_core::ConnectedPoint> for Role {
|
|
|
|
fn from(point: &libp2p_core::ConnectedPoint) -> Self {
|
|
|
|
match point {
|
|
|
|
libp2p_core::ConnectedPoint::Dialer { .. } => Role::Dialer,
|
|
|
|
libp2p_core::ConnectedPoint::Listener { .. } => Role::Listener,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-10-14 18:05:07 +02:00
|
|
|
struct OutgoingConnectionErrorLabels {
|
|
|
|
peer: PeerStatus,
|
|
|
|
error: OutgoingConnectionErrorError,
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Copy, Debug)]
|
2021-10-14 18:05:07 +02:00
|
|
|
enum PeerStatus {
|
|
|
|
Known,
|
|
|
|
Unknown,
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-10-14 18:05:07 +02:00
|
|
|
enum OutgoingConnectionErrorError {
|
|
|
|
Banned,
|
|
|
|
ConnectionLimit,
|
|
|
|
LocalPeerId,
|
|
|
|
NoAddresses,
|
|
|
|
DialPeerConditionFalse,
|
|
|
|
Aborted,
|
|
|
|
InvalidPeerId,
|
2022-01-18 21:21:11 +01:00
|
|
|
WrongPeerId,
|
2021-10-14 18:05:07 +02:00
|
|
|
ConnectionIo,
|
|
|
|
TransportMultiaddrNotSupported,
|
|
|
|
TransportOther,
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelSet, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-08-13 22:51:54 +02:00
|
|
|
struct IncomingConnectionErrorLabels {
|
2021-10-14 18:05:07 +02:00
|
|
|
error: PendingInboundConnectionError,
|
2022-11-15 15:45:14 -05:00
|
|
|
protocols: String,
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
|
2023-01-03 20:42:32 +01:00
|
|
|
#[derive(EncodeLabelValue, Hash, Clone, Eq, PartialEq, Debug)]
|
2021-10-14 18:05:07 +02:00
|
|
|
enum PendingInboundConnectionError {
|
2022-01-18 21:21:11 +01:00
|
|
|
WrongPeerId,
|
2023-01-26 11:20:23 +04:00
|
|
|
LocalPeerId,
|
2021-08-13 22:51:54 +02:00
|
|
|
TransportErrorMultiaddrNotSupported,
|
|
|
|
TransportErrorOther,
|
2021-08-31 17:00:51 +02:00
|
|
|
Aborted,
|
2021-10-14 18:05:07 +02:00
|
|
|
ConnectionLimit,
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
|
2022-12-23 11:13:34 +11:00
|
|
|
impl From<&libp2p_swarm::PendingInboundConnectionError> for PendingInboundConnectionError {
|
|
|
|
fn from(error: &libp2p_swarm::PendingInboundConnectionError) -> Self {
|
2021-10-14 18:05:07 +02:00
|
|
|
match error {
|
2022-02-13 21:57:38 +01:00
|
|
|
libp2p_swarm::PendingInboundConnectionError::WrongPeerId { .. } => {
|
2022-01-18 21:21:11 +01:00
|
|
|
PendingInboundConnectionError::WrongPeerId
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
2023-01-26 11:20:23 +04:00
|
|
|
libp2p_swarm::PendingInboundConnectionError::LocalPeerId { .. } => {
|
|
|
|
PendingInboundConnectionError::LocalPeerId
|
|
|
|
}
|
2022-02-13 21:57:38 +01:00
|
|
|
libp2p_swarm::PendingInboundConnectionError::ConnectionLimit(_) => {
|
2021-10-14 18:05:07 +02:00
|
|
|
PendingInboundConnectionError::ConnectionLimit
|
|
|
|
}
|
2022-02-13 21:57:38 +01:00
|
|
|
libp2p_swarm::PendingInboundConnectionError::Transport(
|
2021-08-13 22:51:54 +02:00
|
|
|
libp2p_core::transport::TransportError::MultiaddrNotSupported(_),
|
2021-10-14 18:05:07 +02:00
|
|
|
) => PendingInboundConnectionError::TransportErrorMultiaddrNotSupported,
|
2022-02-13 21:57:38 +01:00
|
|
|
libp2p_swarm::PendingInboundConnectionError::Transport(
|
2021-08-13 22:51:54 +02:00
|
|
|
libp2p_core::transport::TransportError::Other(_),
|
2021-10-14 18:05:07 +02:00
|
|
|
) => PendingInboundConnectionError::TransportErrorOther,
|
2022-02-13 21:57:38 +01:00
|
|
|
libp2p_swarm::PendingInboundConnectionError::Aborted => {
|
2021-10-14 18:05:07 +02:00
|
|
|
PendingInboundConnectionError::Aborted
|
|
|
|
}
|
2021-08-13 22:51:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
|
|
|
|
fn create_connection_establishment_duration_histogram() -> Histogram {
|
fix(metrics): Update connections_establishment_duration buckets (#3256)
Currently the `libp2p_swarm_connections_establishment_duration` metric has the following buckets:
```
// exponential_buckets(1e-3, 2., 10)
[0.001, 0.002, 0.004, 0.008, 0.016, 0.032, 0.064, 0.128, 0.256, 0.512]
```
It is unlikely that a connection is established in 1ms, even within a datacenter. It is very likely that libp2p connection establishment takes longer than 512ms over the internet.
This commit proposes the following buckets:
```
// exponential_buckets(0.01, 1.5, 20)
[0.01, 0.015, 0.0225, 0.03375, 0.050625, 0.0759375, 0.11390625, 0.170859375, 0.2562890625,
0.38443359375, 0.576650390625, 0.8649755859375, 1.29746337890625, 1.946195068359375,
2.9192926025390626, 4.378938903808594, 6.568408355712891, 9.852612533569337, 14.778918800354004,
22.168378200531006]
```
- Buckets start at 10ms.
- Reasonably high resolution in the sub-second area.
- Largest bucket at 22s, e.g. for a relayed connection.
- Unfortunately rather obscure numbers.
2022-12-17 21:49:09 +01:00
|
|
|
Histogram::new(exponential_buckets(0.01, 1.5, 20))
|
time to establish connection (#3134)
Implementing #2745 , adding a metric to break down time from connection pending to connection established, per protocol stack.
````
$curl -s http://127.0.0.1:42183/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Listener",protocols="/ip4/tcp"} 0.007
libp2p_swarm_connection_establishment_duration_count{role="Listener",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.008"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Listener",protocols="/ip4/tcp",le="+Inf"} 1
lbl@chomp:~lbl
$curl -s http://127.0.0.1:34283/metrics | grep nt_duration
# HELP libp2p_swarm_connection_establishment_duration Time it took (locally) to finish establishing connections.
# TYPE libp2p_swarm_connection_establishment_duration histogram
libp2p_swarm_connection_establishment_duration_sum{role="Dialer",protocols="/ip4/tcp"} 0.009
libp2p_swarm_connection_establishment_duration_count{role="Dialer",protocols="/ip4/tcp"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.001"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.002"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.004"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.008"} 0
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.016"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.032"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.064"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.128"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.256"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="0.512"} 1
libp2p_swarm_connection_establishment_duration_bucket{role="Dialer",protocols="/ip4/tcp",le="+Inf"} 1
````
2022-12-12 09:40:36 -05:00
|
|
|
}
|