iroh_net/relay/server/metrics.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
use iroh_metrics::{
core::{Counter, Metric},
struct_iterable::Iterable,
};
/// Metrics tracked for the relay server
#[allow(missing_docs)]
#[derive(Debug, Clone, Iterable)]
pub struct Metrics {
/*
* Metrics about packets
*/
/// Bytes sent from a `FrameType::SendPacket`
pub bytes_sent: Counter,
/// Bytes received from a `FrameType::SendPacket`
pub bytes_recv: Counter,
/// `FrameType::SendPacket` sent, that are not disco messages
pub send_packets_sent: Counter,
/// `FrameType::SendPacket` received, that are not disco messages
pub send_packets_recv: Counter,
/// `FrameType::SendPacket` dropped, that are not disco messages
pub send_packets_dropped: Counter,
/// `FrameType::SendPacket` sent that are disco messages
pub disco_packets_sent: Counter,
/// `FrameType::SendPacket` received that are disco messages
pub disco_packets_recv: Counter,
/// `FrameType::SendPacket` dropped that are disco messages
pub disco_packets_dropped: Counter,
/// Packets of other `FrameType`s sent
pub other_packets_sent: Counter,
/// Packets of other `FrameType`s received
pub other_packets_recv: Counter,
/// Packets of other `FrameType`s dropped
pub other_packets_dropped: Counter,
/// Number of `FrameType::Ping`s received
pub got_ping: Counter,
/// Number of `FrameType::Pong`s sent
pub sent_pong: Counter,
/// Number of `FrameType::Unknown` received
pub unknown_frames: Counter,
/*
* Metrics about peers
*/
/// Number of connections we have accepted
pub accepts: Counter,
/// Number of connections we have removed because of an error
pub disconnects: Counter,
/// Number of unique client keys per day
pub unique_client_keys: Counter,
/// Number of accepted websocket connections
pub websocket_accepts: Counter,
/// Number of accepted 'iroh derp http' connection upgrades
pub derp_accepts: Counter,
// TODO: enable when we can have multiple connections for one node id
// pub duplicate_client_keys: Counter,
// pub duplicate_client_conns: Counter,
// TODO: only important stat that we cannot track right now
// pub average_queue_duration:
}
impl Default for Metrics {
fn default() -> Self {
Self {
/*
* Metrics about packets
*/
send_packets_sent: Counter::new("Number of 'send' packets relayed."),
bytes_sent: Counter::new("Number of bytes sent."),
send_packets_recv: Counter::new("Number of 'send' packets received."),
bytes_recv: Counter::new("Number of bytes received."),
send_packets_dropped: Counter::new("Number of 'send' packets dropped."),
disco_packets_sent: Counter::new("Number of disco packets sent."),
disco_packets_recv: Counter::new("Number of disco packets received."),
disco_packets_dropped: Counter::new("Number of disco packets dropped."),
other_packets_sent: Counter::new(
"Number of packets sent that were not disco packets or 'send' packets",
),
other_packets_recv: Counter::new(
"Number of packets received that were not disco packets or 'send' packets",
),
other_packets_dropped: Counter::new(
"Number of times a non-disco, non-'send; packet was dropped.",
),
got_ping: Counter::new("Number of times the server has received a Ping from a client."),
sent_pong: Counter::new("Number of times the server has sent a Pong to a client."),
unknown_frames: Counter::new("Number of unknown frames sent to this server."),
/*
* Metrics about peers
*/
accepts: Counter::new("Number of times this server has accepted a connection."),
disconnects: Counter::new("Number of clients that have then disconnected."),
unique_client_keys: Counter::new("Number of unique client keys per day."),
websocket_accepts: Counter::new("Number of accepted websocket connections"),
derp_accepts: Counter::new("Number of accepted 'iroh derp http' connection upgrades"),
// TODO: enable when we can have multiple connections for one node id
// pub duplicate_client_keys: Counter::new("Number of duplicate client keys."),
// pub duplicate_client_conns: Counter::new("Number of duplicate client connections."),
// TODO: only important stat that we cannot track right now
// pub average_queue_duration:
}
}
}
impl Metric for Metrics {
fn name() -> &'static str {
"relayserver"
}
}