mononoke: Add stats aggregation to the API Server

Summary:
The API Server uses Mononoke's blobrepo code and therefore the
stats that they implement. However, without starting a task to aggregate the stats,
they will never be collected.

Spawn the required future on the tokio runtime to allow stats to be exported.

Reviewed By: farnz

Differential Revision: D16280673

fbshipit-source-id: b97efe22208b20b175e67da2c5c0c29f407d0e06
This commit is contained in:
Harvey Hunt 2019-07-16 06:09:51 -07:00 committed by Facebook Github Bot
parent 2ea0f7e6d3
commit 9c49e4a11e

View File

@ -29,6 +29,7 @@ use serde_derive::Deserialize;
use slog::{info, o, Drain, Level, Logger};
use slog_glog_fmt::{kv_categorizer, kv_defaults, GlogFormat};
use slog_logview::LogViewDrain;
use stats::schedule_stats_aggregation;
mod actor;
mod cache;
@ -586,6 +587,9 @@ fn main() -> Fallible<()> {
(None, None)
};
let stats_aggregation =
schedule_stats_aggregation().expect("failed to create stats aggregation scheduler");
let mut runtime = Runtime::new().expect("tokio runtime for blocking jobs");
let repo_configs = RepoConfigs::read_configs(config_path)?;
@ -647,6 +651,10 @@ fn main() -> Fallible<()> {
))?;
let mononoke = Arc::new(mononoke);
runtime.spawn(stats_aggregation.map_err(|err| {
eprintln!("Unexpected error: {:#?}", err);
}));
if let Ok(port) = thrift_port {
thrift::make_thrift(
thrift_logger,