refactor: emit panic metrics for server types

Configures the long-running / server modes to emit panic metrics.
pull/24376/head
Dom Dwyer 2022-04-20 12:28:18 +01:00
parent 49c38c2976
commit c363242902
9 changed files with 35 additions and 14 deletions

View File

@ -370,7 +370,7 @@ pub async fn command(config: Config) -> Result<()> {
info!(?ingester_addresses, "starting querier"); info!(?ingester_addresses, "starting querier");
let querier = create_querier_server_type( let querier = create_querier_server_type(
&common_state, &common_state,
metrics, Arc::clone(&metrics),
catalog, catalog,
object_store, object_store,
time_provider, time_provider,
@ -388,5 +388,5 @@ pub async fn command(config: Config) -> Result<()> {
Service::create_grpc_only(querier, &querier_run_config), Service::create_grpc_only(querier, &querier_run_config),
]; ];
Ok(main::main(common_state, services).await?) Ok(main::main(common_state, services, metrics).await?)
} }

View File

@ -91,7 +91,7 @@ pub async fn command(config: Config) -> Result<(), Error> {
let server_type = create_compactor_server_type( let server_type = create_compactor_server_type(
&common_state, &common_state,
metric_registry, Arc::clone(&metric_registry),
catalog, catalog,
object_store, object_store,
exec, exec,
@ -103,5 +103,5 @@ pub async fn command(config: Config) -> Result<(), Error> {
info!("starting compactor"); info!("starting compactor");
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(common_state, services, metric_registry).await?)
} }

View File

@ -130,5 +130,10 @@ pub async fn command(config: Config) -> Result<()> {
)); ));
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(
common_state,
services,
Arc::new(metric::Registry::default()),
)
.await?)
} }

View File

@ -89,7 +89,7 @@ pub async fn command(config: Config) -> Result<()> {
let exec = Arc::new(Executor::new(config.query_exec_thread_count)); let exec = Arc::new(Executor::new(config.query_exec_thread_count));
let server_type = create_ingester_server_type( let server_type = create_ingester_server_type(
&common_state, &common_state,
metric_registry, Arc::clone(&metric_registry),
catalog, catalog,
object_store, object_store,
exec, exec,
@ -101,5 +101,5 @@ pub async fn command(config: Config) -> Result<()> {
info!("starting ingester"); info!("starting ingester");
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(common_state, services, metric_registry).await?)
} }

View File

@ -1,3 +1,5 @@
use std::sync::Arc;
use ioxd_common::Service; use ioxd_common::Service;
use ioxd_common::{grpc_listener, http_listener, serve, server_type::CommonServerState}; use ioxd_common::{grpc_listener, http_listener, serve, server_type::CommonServerState};
use observability_deps::tracing::{error, info}; use observability_deps::tracing::{error, info};
@ -66,7 +68,11 @@ fn build_malloc_conf() -> String {
/// ///
/// Due to its invasive nature (install global panic handling, /// Due to its invasive nature (install global panic handling,
/// logging, etc) this function should not be used during unit tests. /// logging, etc) this function should not be used during unit tests.
pub async fn main(common_state: CommonServerState, services: Vec<Service>) -> Result<()> { pub async fn main(
common_state: CommonServerState,
services: Vec<Service>,
metrics: Arc<metric::Registry>,
) -> Result<()> {
let git_hash = env!("GIT_HASH", "starting influxdb_iox server"); let git_hash = env!("GIT_HASH", "starting influxdb_iox server");
let num_cpus = num_cpus::get(); let num_cpus = num_cpus::get();
let build_malloc_conf = build_malloc_conf(); let build_malloc_conf = build_malloc_conf();
@ -98,7 +104,7 @@ pub async fn main(common_state: CommonServerState, services: Vec<Service>) -> Re
// lifetime of the program - this is actually a good thing, as it prevents // lifetime of the program - this is actually a good thing, as it prevents
// the panic handler from being removed while unwinding a panic (which in // the panic handler from being removed while unwinding a panic (which in
// turn, causes a panic - see #548) // turn, causes a panic - see #548)
let f = SendPanicsToTracing::new(); let f = SendPanicsToTracing::new().with_metrics(&*metrics);
std::mem::forget(f); std::mem::forget(f);
// Register jemalloc metrics // Register jemalloc metrics

View File

@ -89,7 +89,7 @@ pub async fn command(config: Config) -> Result<(), Error> {
let exec = Arc::new(Executor::new(num_threads)); let exec = Arc::new(Executor::new(num_threads));
let server_type = create_querier_server_type( let server_type = create_querier_server_type(
&common_state, &common_state,
metric_registry, Arc::clone(&metric_registry),
catalog, catalog,
object_store, object_store,
time_provider, time_provider,
@ -101,5 +101,5 @@ pub async fn command(config: Config) -> Result<(), Error> {
info!("starting querier"); info!("starting querier");
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(common_state, services, metric_registry).await?)
} }

View File

@ -159,5 +159,10 @@ pub async fn command(config: Config) -> Result<()> {
)); ));
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(
common_state,
services,
Arc::new(metric::Registry::default()),
)
.await?)
} }

View File

@ -96,5 +96,5 @@ pub async fn command(config: Config) -> Result<()> {
info!("starting router2"); info!("starting router2");
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(common_state, services, metrics).await?)
} }

View File

@ -61,5 +61,10 @@ pub async fn command(config: Config) -> Result<()> {
)); ));
let services = vec![Service::create(server_type, common_state.run_config())]; let services = vec![Service::create(server_type, common_state.run_config())];
Ok(main::main(common_state, services).await?) Ok(main::main(
common_state,
services,
Arc::new(metric::Registry::default()),
)
.await?)
} }