From c41cc0d88375e04e6633714cba2ec4b12dce0823 Mon Sep 17 00:00:00 2001 From: Niklas Date: Mon, 20 Dec 2021 17:17:45 +0000 Subject: [PATCH] feat: add basic stat names --- Cargo.toml | 1 - metrics/Cargo.toml | 2 -- metrics/src/lib.rs | 4 +++ metrics/src/names.rs | 57 +++++++++++++++++++++++++++++++++++++++++++ src/network/server.rs | 2 ++ 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 metrics/src/names.rs diff --git a/Cargo.toml b/Cargo.toml index 6bf1171189..c8f06baebd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,6 @@ cuda = [ "snarkvm/cuda" ] prometheus = ["snarkos-metrics"] test = [] - [dependencies] snarkvm = { git = "https://github.com/AleoHQ/snarkVM.git", rev = "48c59e9" } #snarkvm = { path = "../snarkVM" } diff --git a/metrics/Cargo.toml b/metrics/Cargo.toml index 6e914705b8..a88e7b157c 100644 --- a/metrics/Cargo.toml +++ b/metrics/Cargo.toml @@ -16,8 +16,6 @@ categories = [ "cryptography", "operating-systems" ] license = "GPL-3.0" edition = "2018" -[dependencies] - [dependencies.metrics] version = "0.17" diff --git a/metrics/src/lib.rs b/metrics/src/lib.rs index 3f874ce162..89a6d30123 100644 --- a/metrics/src/lib.rs +++ b/metrics/src/lib.rs @@ -14,8 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the snarkOS library. If not, see . +mod names; + // Re-export the metrics macros. pub use metrics::*; +pub use names::*; + use metrics_exporter_prometheus::PrometheusBuilder; pub fn initialize() -> Option> { diff --git a/metrics/src/names.rs b/metrics/src/names.rs new file mode 100644 index 0000000000..eb5642a6f7 --- /dev/null +++ b/metrics/src/names.rs @@ -0,0 +1,57 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the snarkOS library. + +// The snarkOS library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The snarkOS library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the snarkOS library. If not, see . + +pub mod inbound { + pub const ALL_SUCCESSES: &str = "snarkos_inbound_all_successes_total"; + pub const ALL_FAILURES: &str = "snarkos_inbound_all_failures_total"; + pub const BLOCK_REQUESTS: &str = "snarkos_inbound_block_requests_total"; + pub const BLOCK_RESPONSES: &str = "snarkos_inbound_block_responses_total"; + pub const CHALLENGE_REQUESTS: &str = "snarkos_inbound_challenge_requests_total"; + pub const CHALLENGE_RESPONSES: &str = "snarkos_inbound_challenge_responses_total"; + pub const DISCONNECTS: &str = "snarkos_inbound_disconnects_total"; + pub const PEER_REQUESTS: &str = "snarkos_inbound_peer_requests_total"; + pub const PEER_RESPONSES: &str = "snarkos_inbound_peer_responses_total"; + pub const PINGS: &str = "snarkos_inbound_pings_total"; + pub const PONGS: &str = "snarkos_inbound_pongs_total"; + pub const UNCONFIRMED_BLOCKS: &str = "snarkos_inbound_unconfirmed_blocks_total"; + pub const UNCONFIRMED_TRANSACTIONS: &str = "snarkos_inbound_unconfirmed_transactions_total"; + pub const UNUSED: &str = "snarkos_inbound_unused_total"; +} + +pub mod connections { + pub const ALL_ACCEPTED: &str = "snarkos_connections_all_accepted_total"; + pub const ALL_INITIATED: &str = "snarkos_connections_all_initiated_total"; + pub const ALL_REJECTED: &str = "snarkos_connections_all_rejected_total"; + pub const CONNECTING: &str = "snarkos_connections_connecting_total"; + pub const CONNECTED: &str = "snarkos_connections_connected_total"; + pub const DISCONNECTED: &str = "snarkos_connections_disconnected_total"; +} + +pub mod handshakes { + pub const FAILURES_INIT: &str = "snarkos_handshakes_failures_init_total"; + pub const FAILURES_RESP: &str = "snarkos_handshakes_failures_resp_total"; + pub const SUCCESSES_INIT: &str = "snarkos_handshakes_successes_init_total"; + pub const SUCCESSES_RESP: &str = "snarkos_handshakes_successes_resp_total"; + pub const TIMEOUTS_INIT: &str = "snarkos_handshakes_timeouts_init_total"; + pub const TIMEOUTS_RESP: &str = "snarkos_handshakes_timeouts_resp_total"; +} + +pub mod blocks { + pub const HEIGHT: &str = "snarkos_blocks_height_total"; + pub const MINED: &str = "snarkos_blocks_mined_total"; + pub const DUPLICATES: &str = "snarkos_blocks_duplicates_total"; + pub const ORPHANS: &str = "snarkos_blocks_orphan_total"; +} diff --git a/src/network/server.rs b/src/network/server.rs index 0171982e32..7f30ede416 100644 --- a/src/network/server.rs +++ b/src/network/server.rs @@ -412,5 +412,7 @@ impl Server { #[cfg(feature = "prometheus")] fn initialize_metrics(tasks: &mut Tasks>) { tasks.append(snarkos_metrics::initialize().expect("couldn't initialise the metrics")); + + // TODO: set the block height here, as it could be non-zero. } }