From 91aa9aef4586e0045f2d22005aae4b19dbc20cc2 Mon Sep 17 00:00:00 2001 From: Vlad Lazar Date: Mon, 10 Mar 2025 19:19:25 +0100 Subject: [PATCH] review: separate setting up otel tracing infra --- compute_tools/src/bin/fast_import.rs | 1 - libs/desim/tests/reliable_copy_test.rs | 1 - libs/remote_storage/tests/common/mod.rs | 1 - libs/utils/src/logging.rs | 9 +++++++-- pageserver/compaction/tests/tests.rs | 1 - pageserver/ctl/src/main.rs | 1 - pageserver/pagebench/src/main.rs | 1 - pageserver/src/bin/pageserver.rs | 1 - pageserver/src/tenant.rs | 1 - safekeeper/src/bin/safekeeper.rs | 1 - storage_broker/src/bin/storage_broker.rs | 1 - storage_controller/src/main.rs | 1 - 12 files changed, 7 insertions(+), 13 deletions(-) diff --git a/compute_tools/src/bin/fast_import.rs b/compute_tools/src/bin/fast_import.rs index 265bf8112b..47558be7a0 100644 --- a/compute_tools/src/bin/fast_import.rs +++ b/compute_tools/src/bin/fast_import.rs @@ -592,7 +592,6 @@ pub(crate) async fn main() -> anyhow::Result<()> { utils::logging::init( utils::logging::LogFormat::Json, utils::logging::TracingErrorLayerEnablement::EnableWithRustLogFilter, - utils::logging::OtelEnablement::Disabled, utils::logging::Output::Stdout, )?; diff --git a/libs/desim/tests/reliable_copy_test.rs b/libs/desim/tests/reliable_copy_test.rs index aa73b276af..1ddf9844de 100644 --- a/libs/desim/tests/reliable_copy_test.rs +++ b/libs/desim/tests/reliable_copy_test.rs @@ -158,7 +158,6 @@ mod reliable_copy_test { utils::logging::init( utils::logging::LogFormat::Test, utils::logging::TracingErrorLayerEnablement::Disabled, - utils::logging::OtelEnablement::Disabled, utils::logging::Output::Stdout, ) .expect("logging init failed"); diff --git a/libs/remote_storage/tests/common/mod.rs b/libs/remote_storage/tests/common/mod.rs index d720d61dae..daab05d91a 100644 --- a/libs/remote_storage/tests/common/mod.rs +++ b/libs/remote_storage/tests/common/mod.rs @@ -208,7 +208,6 @@ pub(crate) fn ensure_logging_ready() { utils::logging::init( utils::logging::LogFormat::Test, utils::logging::TracingErrorLayerEnablement::Disabled, - utils::logging::OtelEnablement::Disabled, utils::logging::Output::Stdout, ) .expect("logging init failed"); diff --git a/libs/utils/src/logging.rs b/libs/utils/src/logging.rs index a494985bc0..987a4539e6 100644 --- a/libs/utils/src/logging.rs +++ b/libs/utils/src/logging.rs @@ -10,6 +10,8 @@ use tokio::time::Instant; use tracing::Dispatch; use tracing::info; use tracing::level_filters::LevelFilter; +use tracing_subscriber::Layer; +use tracing_subscriber::layer::SubscriberExt; /// Logs a critical error, similarly to `tracing::error!`. This will: /// @@ -156,9 +158,8 @@ impl Drop for OtelGuard { pub fn init( log_format: LogFormat, tracing_error_layer_enablement: TracingErrorLayerEnablement, - otel_enablement: OtelEnablement, output: Output, -) -> anyhow::Result> { +) -> anyhow::Result<()> { // We fall back to printing all spans at info-level or above if // the RUST_LOG environment variable is not set. let rust_log_env_filter = || { @@ -198,6 +199,10 @@ pub fn init( TracingErrorLayerEnablement::Disabled => r.init(), } + Ok(()) +} + +pub fn init_otel_tracing(otel_enablement: OtelEnablement) -> anyhow::Result> { let otel_subscriber = match otel_enablement { OtelEnablement::Disabled => None, OtelEnablement::Enabled { diff --git a/pageserver/compaction/tests/tests.rs b/pageserver/compaction/tests/tests.rs index 7db1e0e2d6..565f66ce1a 100644 --- a/pageserver/compaction/tests/tests.rs +++ b/pageserver/compaction/tests/tests.rs @@ -10,7 +10,6 @@ pub(crate) fn setup_logging() { logging::init( logging::LogFormat::Test, logging::TracingErrorLayerEnablement::EnableWithRustLogFilter, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, ) .expect("Failed to init test logging"); diff --git a/pageserver/ctl/src/main.rs b/pageserver/ctl/src/main.rs index 957537cc8e..72a120a69b 100644 --- a/pageserver/ctl/src/main.rs +++ b/pageserver/ctl/src/main.rs @@ -117,7 +117,6 @@ async fn main() -> anyhow::Result<()> { logging::init( LogFormat::Plain, TracingErrorLayerEnablement::EnableWithRustLogFilter, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, )?; diff --git a/pageserver/pagebench/src/main.rs b/pageserver/pagebench/src/main.rs index fb017de119..5527557450 100644 --- a/pageserver/pagebench/src/main.rs +++ b/pageserver/pagebench/src/main.rs @@ -35,7 +35,6 @@ fn main() { logging::init( logging::LogFormat::Plain, logging::TracingErrorLayerEnablement::Disabled, - utils::logging::OtelEnablement::Disabled, logging::Output::Stderr, ) .unwrap(); diff --git a/pageserver/src/bin/pageserver.rs b/pageserver/src/bin/pageserver.rs index baa70f8083..36ca91c04a 100644 --- a/pageserver/src/bin/pageserver.rs +++ b/pageserver/src/bin/pageserver.rs @@ -114,7 +114,6 @@ fn main() -> anyhow::Result<()> { logging::init( conf.log_format, tracing_error_layer_enablement, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, )?; diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index d877d2eb1c..793f112992 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -5718,7 +5718,6 @@ pub(crate) mod harness { // enable it in case the tests exercise code paths that use // debug_assert_current_span_has_tenant_and_timeline_id logging::TracingErrorLayerEnablement::EnableWithRustLogFilter, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, ) .expect("Failed to init test logging"); diff --git a/safekeeper/src/bin/safekeeper.rs b/safekeeper/src/bin/safekeeper.rs index 73e8eae57e..10fc4a4b59 100644 --- a/safekeeper/src/bin/safekeeper.rs +++ b/safekeeper/src/bin/safekeeper.rs @@ -255,7 +255,6 @@ async fn main() -> anyhow::Result<()> { logging::init( LogFormat::from_config(&args.log_format)?, logging::TracingErrorLayerEnablement::Disabled, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, )?; logging::replace_panic_hook_with_tracing_panic_hook().forget(); diff --git a/storage_broker/src/bin/storage_broker.rs b/storage_broker/src/bin/storage_broker.rs index 61962e1e94..cc33ec20ff 100644 --- a/storage_broker/src/bin/storage_broker.rs +++ b/storage_broker/src/bin/storage_broker.rs @@ -643,7 +643,6 @@ async fn main() -> Result<(), Box> { logging::init( LogFormat::from_config(&args.log_format)?, logging::TracingErrorLayerEnablement::Disabled, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, )?; logging::replace_panic_hook_with_tracing_panic_hook().forget(); diff --git a/storage_controller/src/main.rs b/storage_controller/src/main.rs index 5c954b6838..1d49cd85ca 100644 --- a/storage_controller/src/main.rs +++ b/storage_controller/src/main.rs @@ -240,7 +240,6 @@ fn main() -> anyhow::Result<()> { logging::init( LogFormat::Plain, logging::TracingErrorLayerEnablement::Disabled, - utils::logging::OtelEnablement::Disabled, logging::Output::Stdout, )?;