mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 12:58:31 +00:00
Additional networking metrics (#2549)
Adds additional metrics for network monitoring and evaluation. Co-authored-by: Mark Mackey <mark@sigmaprime.io>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
mod metrics;
|
||||
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use lighthouse_network::open_metrics_client::registry::Registry;
|
||||
use lighthouse_version::version_with_platform;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slog::{crit, info, Logger};
|
||||
@@ -39,6 +40,7 @@ pub struct Context<T: BeaconChainTypes> {
|
||||
pub chain: Option<Arc<BeaconChain<T>>>,
|
||||
pub db_path: Option<PathBuf>,
|
||||
pub freezer_db_path: Option<PathBuf>,
|
||||
pub gossipsub_registry: Option<std::sync::Mutex<Registry>>,
|
||||
pub log: Logger,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::Context;
|
||||
use beacon_chain::BeaconChainTypes;
|
||||
use lighthouse_metrics::{Encoder, TextEncoder};
|
||||
use lighthouse_network::open_metrics_client::encoding::text::encode;
|
||||
use malloc_utils::scrape_allocator_metrics;
|
||||
|
||||
pub use lighthouse_metrics::*;
|
||||
@@ -51,6 +52,12 @@ pub fn gather_prometheus_metrics<T: BeaconChainTypes>(
|
||||
encoder
|
||||
.encode(&lighthouse_metrics::gather(), &mut buffer)
|
||||
.unwrap();
|
||||
// encode gossipsub metrics also if they exist
|
||||
if let Some(registry) = ctx.gossipsub_registry.as_ref() {
|
||||
if let Ok(registry_locked) = registry.lock() {
|
||||
let _ = encode(&mut buffer, ®istry_locked);
|
||||
}
|
||||
}
|
||||
|
||||
String::from_utf8(buffer).map_err(|e| format!("Failed to encode prometheus info: {:?}", e))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user