Skip to content

Commit

Permalink
Merge pull request #3097 from eqlabs/feat/more_metrics
Browse files Browse the repository at this point in the history
feat: more metrics
  • Loading branch information
howardwu authored Feb 15, 2024
2 parents d70782e + f7eaf84 commit 13a54f2
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 81 deletions.
116 changes: 58 additions & 58 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ default-features = false

[workspace.dependencies.snarkvm]
git = "https://github.com/AleoHQ/snarkVM.git"
rev = "6e182c6"
rev = "b396a51"
#version = "=0.16.18"
features = [ "circuit", "console", "rocks" ]

Expand Down
2 changes: 1 addition & 1 deletion node/bft/events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"

[features]
default = [ ]
metrics = [ "dep:metrics" ]
metrics = ["dep:metrics", "snarkvm/metrics"]

[dependencies.anyhow]
version = "1.0"
Expand Down
14 changes: 12 additions & 2 deletions node/bft/events/src/helpers/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,21 @@ impl<N: Network> Decoder for EventCodec<N> {
Some(bytes) => bytes,
None => return Ok(None),
};

#[cfg(feature = "metrics")]
let num_bytes = bytes.len() as f64;
// Convert the bytes to an event, or fail if it is not valid.
let reader = bytes.reader();
match Event::read_le(reader) {
Ok(event) => Ok(Some(event)),
Ok(event) => {
#[cfg(feature = "metrics")]
metrics::histogram_label(
metrics::tcp::TCP_GATEWAY,
"event",
String::from(event.name().clone()),
num_bytes,
);
Ok(Some(event))
}
Err(error) => {
error!("Failed to deserialize an event: {}", error);
Err(std::io::ErrorKind::InvalidData.into())
Expand Down
3 changes: 3 additions & 0 deletions node/bft/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@ impl<N: Network> Primary<N> {
self.reinsert_transmissions_into_workers(proposal)?;
return Err(e);
}

#[cfg(feature = "metrics")]
metrics::increment_gauge(metrics::bft::CERTIFIED_BATCHES, 1.0);
Ok(())
}

Expand Down
108 changes: 91 additions & 17 deletions node/metrics/snarkOS-grafana.json
Original file line number Diff line number Diff line change
Expand Up @@ -979,13 +979,84 @@
"title": "Elected Leaders",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 6,
"x": 0,
"y": 42
},
"id": 40,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"disableTextWrap": false,
"editorMode": "builder",
"expr": "snarkos_bft_primary_certified_batches",
"fullMetaSearch": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "__auto",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Certified Batches",
"type": "stat"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 42
"y": 50
},
"id": 10,
"panels": [],
Expand Down Expand Up @@ -1057,7 +1128,7 @@
"h": 8,
"w": 9,
"x": 0,
"y": 43
"y": 51
},
"id": 8,
"options": {
Expand Down Expand Up @@ -1181,7 +1252,7 @@
"h": 8,
"w": 9,
"x": 9,
"y": 43
"y": 51
},
"id": 14,
"options": {
Expand Down Expand Up @@ -1274,16 +1345,15 @@
"value": 80
}
]
},
"unit": "s"
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 6,
"y": 51
"y": 59
},
"id": 38,
"options": {
Expand Down Expand Up @@ -1325,7 +1395,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 59
"y": 67
},
"id": 4,
"panels": [],
Expand Down Expand Up @@ -1396,7 +1466,7 @@
"h": 8,
"w": 12,
"x": 6,
"y": 60
"y": 68
},
"id": 37,
"options": {
Expand Down Expand Up @@ -1480,7 +1550,8 @@
"mode": "absolute",
"steps": [
{
"color": "green"
"color": "green",
"value": null
},
{
"color": "red",
Expand All @@ -1496,7 +1567,7 @@
"h": 8,
"w": 12,
"x": 0,
"y": 68
"y": 76
},
"id": 32,
"options": {
Expand Down Expand Up @@ -1580,7 +1651,8 @@
"mode": "absolute",
"steps": [
{
"color": "green"
"color": "green",
"value": null
},
{
"color": "red",
Expand All @@ -1596,7 +1668,7 @@
"h": 8,
"w": 12,
"x": 12,
"y": 68
"y": 76
},
"id": 33,
"options": {
Expand Down Expand Up @@ -1683,7 +1755,8 @@
"mode": "absolute",
"steps": [
{
"color": "green"
"color": "green",
"value": null
},
{
"color": "red",
Expand All @@ -1699,7 +1772,7 @@
"h": 8,
"w": 12,
"x": 0,
"y": 76
"y": 84
},
"id": 34,
"options": {
Expand Down Expand Up @@ -1783,7 +1856,8 @@
"mode": "absolute",
"steps": [
{
"color": "green"
"color": "green",
"value": null
},
{
"color": "red",
Expand All @@ -1799,7 +1873,7 @@
"h": 8,
"w": 12,
"x": 12,
"y": 76
"y": 84
},
"id": 35,
"options": {
Expand Down Expand Up @@ -1867,6 +1941,6 @@
"timezone": "",
"title": "snarkOS",
"uid": "ahTJm4-4k",
"version": 1,
"version": 2,
"weekStart": ""
}
8 changes: 6 additions & 2 deletions node/metrics/src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@

pub(super) const COUNTER_NAMES: [&str; 1] = [bft::LEADERS_ELECTED];

pub(super) const GAUGE_NAMES: [&str; 12] = [
pub(super) const GAUGE_NAMES: [&str; 13] = [
bft::CONNECTED,
bft::CONNECTING,
bft::LAST_STORED_ROUND,
bft::PROPOSAL_ROUND,
bft::CERTIFIED_BATCHES,
blocks::HEIGHT,
blocks::TRANSACTIONS,
consensus::COMMITTED_CERTIFICATES,
Expand All @@ -29,14 +30,15 @@ pub(super) const GAUGE_NAMES: [&str; 12] = [
tcp::TCP_TASKS,
];

pub(super) const HISTOGRAM_NAMES: [&str; 7] = [
pub(super) const HISTOGRAM_NAMES: [&str; 8] = [
bft::COMMIT_ROUNDS_LATENCY,
consensus::CERTIFICATE_COMMIT_LATENCY,
consensus::BLOCK_LATENCY,
tcp::NOISE_CODEC_ENCRYPTION_TIME,
tcp::NOISE_CODEC_DECRYPTION_TIME,
tcp::NOISE_CODEC_ENCRYPTION_SIZE,
tcp::NOISE_CODEC_DECRYPTION_SIZE,
tcp::TCP_GATEWAY,
];

pub mod bft {
Expand All @@ -46,6 +48,7 @@ pub mod bft {
pub const LAST_STORED_ROUND: &str = "snarkos_bft_last_stored_round";
pub const LEADERS_ELECTED: &str = "snarkos_bft_leaders_elected_total";
pub const PROPOSAL_ROUND: &str = "snarkos_bft_primary_proposal_round";
pub const CERTIFIED_BATCHES: &str = "snarkos_bft_primary_certified_batches";
}

pub mod blocks {
Expand All @@ -72,4 +75,5 @@ pub mod tcp {
pub const NOISE_CODEC_ENCRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_encryption_size";
pub const NOISE_CODEC_DECRYPTION_SIZE: &str = "snarkos_tcp_noise_codec_decryption_size";
pub const TCP_TASKS: &str = "snarkos_tcp_tasks_total";
pub const TCP_GATEWAY: &str = "snarkos_tcp_gateway_messages_received";
}

0 comments on commit 13a54f2

Please sign in to comment.