use crate::runtime::MetricType;
use alloc::{vec, vec::Vec};
pub const NUM_CONNECTIONS: &str = "ntcp2_connection_count";
pub const HANDSHAKE_DURATION: &str = "ntcp2_handshake_duration_buckets";
pub const NUM_HANDSHAKE_FAILURES: &str = "ntcp2_handshake_failure_count";
pub const NUM_HANDSHAKE_SUCCESSES: &str = "ntcp2_handshake_success_count";
pub const NUM_INBOUND_NTCP2: &str = "ntcp2_inbound_count";
pub const NUM_OUTBOUND_NTCP2: &str = "ntcp2_outbound_count";
pub const INBOUND_BW: &str = "ntcp2_inbound_bw_count";
pub const OUTBOUND_BW: &str = "ntcp2_outbound_bw_count";
pub const CONNECTIONS_OPENED: &str = "ntcp2_connections_opened_count";
pub const CONNECTIONS_CLOSED: &str = "ntcp2_connections_closed_count";
pub const NUM_BLOCKS_PER_MSG: &str = "ntcp2_blocks_per_msg";
pub const MESSAGE_SIZES: &str = "ntcp2_msg_sizes";
pub const NUM_INBOUND_MESSAGES: &str = "ntcp2_num_inbound_msgs";
pub const NUM_OUTBOUND_MESSAGES: &str = "ntcp2_num_outbound_msgs";
pub fn register_metrics(mut metrics: Vec<MetricType>) -> Vec<MetricType> {
metrics.push(MetricType::Counter {
name: NUM_HANDSHAKE_SUCCESSES,
description: "how many times the ssu2 handshake has succeeded",
});
metrics.push(MetricType::Counter {
name: NUM_HANDSHAKE_FAILURES,
description: "how many times the ssu2 handshake has failed",
});
metrics.push(MetricType::Counter {
name: NUM_INBOUND_MESSAGES,
description: "how many inbound ntcp2 messages have been received",
});
metrics.push(MetricType::Counter {
name: NUM_OUTBOUND_MESSAGES,
description: "how many outbound ntcp2 messages have been sent",
});
metrics.push(MetricType::Counter {
name: INBOUND_BW,
description: "inbound bandwidth",
});
metrics.push(MetricType::Counter {
name: OUTBOUND_BW,
description: "outbound bandwidth",
});
metrics.push(MetricType::Counter {
name: CONNECTIONS_OPENED,
description: "how many connections have been opened",
});
metrics.push(MetricType::Counter {
name: CONNECTIONS_CLOSED,
description: "how many connections have been closed",
});
metrics.push(MetricType::Gauge {
name: NUM_CONNECTIONS,
description: "how many active ssu2 connections there are",
});
metrics.push(MetricType::Histogram {
name: HANDSHAKE_DURATION,
description: "how long it takes for the handshake to finish",
buckets: vec![
50f64, 100f64, 150f64, 200f64, 250f64, 300f64, 350f64, 400f64, 450f64, 500f64, 600f64,
700f64, 800f64, 900f64, 1000f64, 3000f64, 5000f64, 10_000f64,
],
});
metrics.push(MetricType::Histogram {
name: NUM_BLOCKS_PER_MSG,
description: "number of blocks per message",
buckets: vec![1f64, 2f64, 3f64, 4f64, 5f64, 8f64, 10f64, 15f64, 20f64],
});
metrics.push(MetricType::Histogram {
name: MESSAGE_SIZES,
description: "size of ntcp2 message",
buckets: vec![
512f64, 1000f64, 1500f64, 2000f64, 5000f64, 10_000f64, 25_000f64, 50_000f64,
],
});
metrics
}