review: separate setting up otel tracing infra

This commit is contained in:
Vlad Lazar
2025-03-10 19:19:25 +01:00
parent 1f3d655708
commit 91aa9aef45
12 changed files with 7 additions and 13 deletions

View File

@@ -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,
)?;

View File

@@ -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");

View File

@@ -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");

View File

@@ -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<Option<OtelGuard>> {
) -> 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<Option<OtelGuard>> {
let otel_subscriber = match otel_enablement {
OtelEnablement::Disabled => None,
OtelEnablement::Enabled {

View File

@@ -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");

View File

@@ -117,7 +117,6 @@ async fn main() -> anyhow::Result<()> {
logging::init(
LogFormat::Plain,
TracingErrorLayerEnablement::EnableWithRustLogFilter,
utils::logging::OtelEnablement::Disabled,
logging::Output::Stdout,
)?;

View File

@@ -35,7 +35,6 @@ fn main() {
logging::init(
logging::LogFormat::Plain,
logging::TracingErrorLayerEnablement::Disabled,
utils::logging::OtelEnablement::Disabled,
logging::Output::Stderr,
)
.unwrap();

View File

@@ -114,7 +114,6 @@ fn main() -> anyhow::Result<()> {
logging::init(
conf.log_format,
tracing_error_layer_enablement,
utils::logging::OtelEnablement::Disabled,
logging::Output::Stdout,
)?;

View File

@@ -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");

View File

@@ -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();

View File

@@ -643,7 +643,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
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();

View File

@@ -240,7 +240,6 @@ fn main() -> anyhow::Result<()> {
logging::init(
LogFormat::Plain,
logging::TracingErrorLayerEnablement::Disabled,
utils::logging::OtelEnablement::Disabled,
logging::Output::Stdout,
)?;