Add process metrics to http-server

This commit is contained in:
Paul Hauner 2019-05-30 12:36:27 +10:00
parent 4851d8be03
commit f44170cab1
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
2 changed files with 6 additions and 2 deletions

View File

@ -20,7 +20,7 @@ fork_choice = { path = "../../eth2/fork_choice" }
grpcio = { version = "0.4", default-features = false, features = ["protobuf-codec"] }
persistent = "^0.4"
protobuf = "2.0.2"
prometheus = "^0.6"
prometheus = { version = "^0.6", features = ["process"] }
clap = "2.32.0"
store = { path = "../store" }
dirs = "1.0.3"

View File

@ -90,9 +90,13 @@ fn handle_metrics<T: BeaconChainTypes + 'static>(req: &mut Request) -> IronResul
let validator_count = beacon_chain.head().beacon_state.validator_registry.len();
local_metrics.validator_count.set(validator_count as i64);
// Gather the metrics.
let mut buffer = vec![];
let encoder = TextEncoder::new();
// Gather `DEFAULT_REGISTRY` metrics.
encoder.encode(&prometheus::gather(), &mut buffer).unwrap();
// Gather metrics from our registry.
let metric_families = r.gather();
encoder.encode(&metric_families, &mut buffer).unwrap();