mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-27 01:33:33 +00:00
Clean up database metrics, add freezer DB size (#715)
* Clean up database metrics, add freezer DB size * Address review comments
This commit is contained in:
committed by
Paul Hauner
parent
b9d00ee8b8
commit
5e7803f00b
@@ -56,6 +56,7 @@ pub fn start_server<T: BeaconChainTypes>(
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
network_info: NetworkInfo<T>,
|
||||
db_path: PathBuf,
|
||||
freezer_db_path: PathBuf,
|
||||
eth2_config: Eth2Config,
|
||||
log: slog::Logger,
|
||||
) -> Result<(exit_future::Signal, SocketAddr), hyper::Error> {
|
||||
@@ -70,6 +71,7 @@ pub fn start_server<T: BeaconChainTypes>(
|
||||
let network_service = network_info.network_service.clone();
|
||||
let network_channel = Arc::new(RwLock::new(network_info.network_chan.clone()));
|
||||
let db_path = db_path.clone();
|
||||
let freezer_db_path = freezer_db_path.clone();
|
||||
|
||||
service_fn(move |req: Request<Body>| {
|
||||
router::route(
|
||||
@@ -80,6 +82,7 @@ pub fn start_server<T: BeaconChainTypes>(
|
||||
eth2_config.clone(),
|
||||
log.clone(),
|
||||
db_path.clone(),
|
||||
freezer_db_path.clone(),
|
||||
)
|
||||
})
|
||||
});
|
||||
|
||||
@@ -32,6 +32,7 @@ pub fn get_prometheus<T: BeaconChainTypes>(
|
||||
req: Request<Body>,
|
||||
beacon_chain: Arc<BeaconChain<T>>,
|
||||
db_path: PathBuf,
|
||||
freezer_db_path: PathBuf,
|
||||
) -> ApiResult {
|
||||
let mut buffer = vec![];
|
||||
let encoder = TextEncoder::new();
|
||||
@@ -53,7 +54,7 @@ pub fn get_prometheus<T: BeaconChainTypes>(
|
||||
// a string that can be returned via HTTP.
|
||||
|
||||
slot_clock::scrape_for_metrics::<T::EthSpec, T::SlotClock>(&beacon_chain.slot_clock);
|
||||
store::scrape_for_metrics(&db_path);
|
||||
store::scrape_for_metrics(&db_path, &freezer_db_path);
|
||||
beacon_chain::scrape_for_metrics(&beacon_chain);
|
||||
|
||||
encoder
|
||||
|
||||
@@ -27,6 +27,7 @@ pub fn route<T: BeaconChainTypes>(
|
||||
eth2_config: Arc<Eth2Config>,
|
||||
local_log: slog::Logger,
|
||||
db_path: PathBuf,
|
||||
freezer_db_path: PathBuf,
|
||||
) -> impl Future<Item = Response<Body>, Error = Error> {
|
||||
metrics::inc_counter(&metrics::REQUEST_COUNT);
|
||||
let timer = metrics::start_timer(&metrics::REQUEST_RESPONSE_TIME);
|
||||
@@ -143,9 +144,12 @@ pub fn route<T: BeaconChainTypes>(
|
||||
into_boxfut(spec::get_eth2_config::<T>(req, eth2_config))
|
||||
}
|
||||
|
||||
(&Method::GET, "/metrics") => {
|
||||
into_boxfut(metrics::get_prometheus::<T>(req, beacon_chain, db_path))
|
||||
}
|
||||
(&Method::GET, "/metrics") => into_boxfut(metrics::get_prometheus::<T>(
|
||||
req,
|
||||
beacon_chain,
|
||||
db_path,
|
||||
freezer_db_path,
|
||||
)),
|
||||
|
||||
_ => Box::new(futures::future::err(ApiError::NotFound(
|
||||
"Request path and/or method not found.".to_owned(),
|
||||
|
||||
Reference in New Issue
Block a user