diff --git a/doc/dev-guide/src/tracing.md b/doc/dev-guide/src/tracing.md index 0a26be1b4cf..f0547931929 100644 --- a/doc/dev-guide/src/tracing.md +++ b/doc/dev-guide/src/tracing.md @@ -52,7 +52,7 @@ when enabled. Instrumenting a currently uninstrumented function is mostly simply done like so: ```rust -#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))] +#[tracing::instrument(level = "trace", err, skip_all)] ``` `skip_all` is not required, but some core structs don't implement Debug yet, and diff --git a/rustup-macros/src/lib.rs b/rustup-macros/src/lib.rs index 1dfe6800c8b..05eaaf5f5d7 100644 --- a/rustup-macros/src/lib.rs +++ b/rustup-macros/src/lib.rs @@ -98,7 +98,7 @@ fn test_inner(mod_path: String, mut input: ItemFn) -> syn::Result { #before_ident().await; // Define a function with same name we can instrument inside the // tracing enablement logic. - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] async fn #name() { #inner } // Thunk through a new thread to permit catching the panic // without grabbing the entire state machine defined by the diff --git a/src/bin/rustup-init.rs b/src/bin/rustup-init.rs index 92a175b237d..cb86cdff68e 100644 --- a/src/bin/rustup-init.rs +++ b/src/bin/rustup-init.rs @@ -67,8 +67,7 @@ async fn maybe_trace_rustup() -> Result { result } -// FIXME: Make `tracing::instrument` always run -#[cfg_attr(feature = "otel", tracing::instrument)] +#[tracing::instrument(level = "trace")] async fn run_rustup() -> Result { if let Ok(dir) = process().var("RUSTUP_TRACE_DIR") { open_trace_file!(dir)?; @@ -80,7 +79,7 @@ async fn run_rustup() -> Result { result } -#[cfg_attr(feature = "otel", tracing::instrument(err))] +#[tracing::instrument(level = "trace", err)] async fn run_rustup_inner() -> Result { // Guard against infinite proxy recursion. This mostly happens due to // bugs in rustup. diff --git a/src/cli/common.rs b/src/cli/common.rs index bb0000d6634..b7752372dd9 100644 --- a/src/cli/common.rs +++ b/src/cli/common.rs @@ -179,7 +179,7 @@ impl Notifier { } } -#[cfg_attr(feature = "otel", tracing::instrument)] +#[tracing::instrument(level = "trace")] pub(crate) fn set_globals(current_dir: PathBuf, verbose: bool, quiet: bool) -> Result { let notifier = Notifier::new(verbose, quiet); Cfg::from_env(current_dir, Arc::new(move |n| notifier.handle(n))) diff --git a/src/cli/proxy_mode.rs b/src/cli/proxy_mode.rs index 1a81999e5f8..2febb7d4d8c 100644 --- a/src/cli/proxy_mode.rs +++ b/src/cli/proxy_mode.rs @@ -10,7 +10,7 @@ use crate::{ toolchain::names::ResolvableLocalToolchainName, }; -#[cfg_attr(feature = "otel", tracing::instrument)] +#[tracing::instrument(level = "trace")] pub async fn main(arg0: &str, current_dir: PathBuf) -> Result { self_update::cleanup_self_updater()?; diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 2add7bc982c..55cb5b69b24 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -535,7 +535,7 @@ enum SetSubcmd { }, } -#[cfg_attr(feature = "otel", tracing::instrument(fields(args = format!("{:?}", process().args_os().collect::>()))))] +#[tracing::instrument(level = "trace", fields(args = format!("{:?}", process().args_os().collect::>())))] pub async fn main(current_dir: PathBuf) -> Result { self_update::cleanup_self_updater()?; @@ -550,7 +550,7 @@ pub async fn main(current_dir: PathBuf) -> Result { write!(process().stdout().lock(), "{err}")?; info!("This is the version for the rustup toolchain manager, not the rustc compiler."); - #[cfg_attr(feature = "otel", tracing::instrument)] + #[tracing::instrument(level = "trace")] async fn rustc_version( current_dir: PathBuf, ) -> std::result::Result> { @@ -938,7 +938,7 @@ async fn which( Ok(utils::ExitCode(0)) } -#[cfg_attr(feature = "otel", tracing::instrument(skip_all))] +#[tracing::instrument(level = "trace", skip_all)] fn show(cfg: &Cfg, verbose: bool) -> Result { common::warn_if_host_is_emulated(); @@ -1075,7 +1075,7 @@ fn show(cfg: &Cfg, verbose: bool) -> Result { Ok(utils::ExitCode(0)) } -#[cfg_attr(feature = "otel", tracing::instrument(skip_all))] +#[tracing::instrument(level = "trace", skip_all)] fn show_active_toolchain(cfg: &Cfg, verbose: bool) -> Result { match cfg.find_active_toolchain()? { Some((toolchain_name, reason)) => { @@ -1099,7 +1099,7 @@ fn show_active_toolchain(cfg: &Cfg, verbose: bool) -> Result { Ok(utils::ExitCode(0)) } -#[cfg_attr(feature = "otel", tracing::instrument(skip_all))] +#[tracing::instrument(level = "trace", skip_all)] fn show_rustup_home(cfg: &Cfg) -> Result { writeln!(process().stdout().lock(), "{}", cfg.rustup_dir.display())?; Ok(utils::ExitCode(0)) diff --git a/src/cli/self_update.rs b/src/cli/self_update.rs index 7f6dc8965ea..10eeb4633f1 100644 --- a/src/cli/self_update.rs +++ b/src/cli/self_update.rs @@ -1321,7 +1321,7 @@ pub(crate) async fn check_rustup_update() -> Result<()> { Ok(()) } -#[cfg_attr(feature = "otel", tracing::instrument)] +#[tracing::instrument(level = "trace")] pub(crate) fn cleanup_self_updater() -> Result<()> { let cargo_home = utils::cargo_home()?; let setup = cargo_home.join(format!("bin/rustup-init{EXE_SUFFIX}")); diff --git a/src/cli/self_update/windows.rs b/src/cli/self_update/windows.rs index cd046bb6d48..c123668131e 100644 --- a/src/cli/self_update/windows.rs +++ b/src/cli/self_update/windows.rs @@ -264,7 +264,7 @@ fn has_windows_sdk_libs() -> bool { } /// Run by rustup-gc-$num.exe to delete CARGO_HOME -#[cfg_attr(feature = "otel", tracing::instrument)] +#[tracing::instrument(level = "trace")] pub fn complete_windows_uninstall() -> Result { use std::process::Stdio; diff --git a/src/cli/setup_mode.rs b/src/cli/setup_mode.rs index 49dcbb3bb3e..b9f7d0f80d3 100644 --- a/src/cli/setup_mode.rs +++ b/src/cli/setup_mode.rs @@ -75,7 +75,7 @@ struct RustupInit { dump_testament: bool, } -#[cfg_attr(feature = "otel", tracing::instrument)] +#[tracing::instrument(level = "trace")] pub async fn main(current_dir: PathBuf) -> Result { use clap::error::ErrorKind; diff --git a/src/command.rs b/src/command.rs index 35dddd3dc83..c929fd0388f 100644 --- a/src/command.rs +++ b/src/command.rs @@ -9,7 +9,7 @@ use anyhow::{Context, Result}; use crate::errors::*; -#[cfg_attr(feature = "otel", tracing::instrument(err))] +#[tracing::instrument(level = "trace", err)] pub(crate) fn run_command_for_dir + Debug>( mut cmd: Command, arg0: &str, diff --git a/src/config.rs b/src/config.rs index 45ad21380a2..0fa408a0831 100644 --- a/src/config.rs +++ b/src/config.rs @@ -456,7 +456,7 @@ impl Cfg { Ok(self.update_hash_dir.join(toolchain.to_string())) } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) fn upgrade_data(&self) -> Result<()> { let current_version = self.settings_file.with(|s| Ok(s.version))?; if current_version == MetadataVersion::default() { @@ -693,7 +693,7 @@ impl Cfg { .ok_or_else(no_toolchain_error) } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) async fn maybe_find_or_install_active_toolchain( &self, path: &Path, @@ -801,7 +801,7 @@ impl Cfg { /// - not files /// - named with a valid resolved toolchain name /// Currently no notification of incorrect names or entry type is done. - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) fn list_toolchains(&self) -> Result> { if utils::is_directory(&self.toolchains_dir) { let mut toolchains: Vec<_> = utils::read_dir("toolchains", &self.toolchains_dir)? @@ -871,7 +871,7 @@ impl Cfg { Ok(channels.collect().await) } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) fn check_metadata_version(&self) -> Result<()> { utils::assert_is_directory(&self.rustup_dir)?; @@ -899,7 +899,7 @@ impl Cfg { }) } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) fn get_default_host_triple(&self) -> Result { self.settings_file.with(|s| Ok(get_default_host_triple(s))) } diff --git a/src/dist/dist.rs b/src/dist/dist.rs index ee38dbd8c4b..998eb4d0924 100644 --- a/src/dist/dist.rs +++ b/src/dist/dist.rs @@ -701,7 +701,7 @@ pub(crate) fn valid_profile_names() -> String { // an upgrade then all the existing components will be upgraded. // // Returns the manifest's hash if anything changed. -#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all, fields(profile=format!("{profile:?}"), prefix=prefix.path().to_string_lossy().to_string())))] +#[tracing::instrument(level = "trace", err, skip_all, fields(profile=format!("{profile:?}"), prefix=prefix.path().to_string_lossy().to_string()))] pub(crate) async fn update_from_dist( download: DownloadCfg<'_>, update_hash: Option<&Path>, diff --git a/src/dist/manifestation.rs b/src/dist/manifestation.rs index 6abf92eb827..6719cf17280 100644 --- a/src/dist/manifestation.rs +++ b/src/dist/manifestation.rs @@ -376,7 +376,7 @@ impl Manifestation { } } - #[cfg_attr(feature = "otel", tracing::instrument)] + #[tracing::instrument(level = "trace")] pub fn load_manifest(&self) -> Result> { let prefix = self.installation.prefix(); let old_manifest_path = prefix.manifest_file(DIST_MANIFEST); diff --git a/src/install.rs b/src/install.rs index 922570ede7f..7aa5734e4fe 100644 --- a/src/install.rs +++ b/src/install.rs @@ -58,7 +58,7 @@ pub(crate) enum InstallMethod<'a> { impl<'a> InstallMethod<'a> { // Install a toolchain - #[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))] + #[tracing::instrument(level = "trace", err, skip_all)] pub(crate) async fn install(&self) -> Result { let nh = self.cfg().notify_handler.clone(); match self { diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs index 9c3236fcb64..8265825fcfd 100644 --- a/src/test/mock/clitools.rs +++ b/src/test/mock/clitools.rs @@ -902,7 +902,7 @@ impl Release { } } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] fn link(&self, path: &Path) { // Also create the manifests for releases by version let _ = hard_link( @@ -955,7 +955,7 @@ impl Release { } // Creates a mock dist server populated with some test data -#[cfg_attr(feature = "otel", tracing::instrument(skip_all))] +#[tracing::instrument(level = "trace", skip_all)] fn create_mock_dist_server(path: &Path, s: Scenario) { let chans = match s { Scenario::None => return, diff --git a/src/test/mock/dist.rs b/src/test/mock/dist.rs index bc606411c92..77cc42abd40 100644 --- a/src/test/mock/dist.rs +++ b/src/test/mock/dist.rs @@ -130,7 +130,7 @@ pub enum MockManifestVersion { } impl MockDistServer { - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub fn write(&self, vs: &[MockManifestVersion], enable_xz: bool, enable_zst: bool) { fs::create_dir_all(&self.path).unwrap(); @@ -149,7 +149,7 @@ impl MockDistServer { } } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] fn build_package( &self, channel: &MockChannel, @@ -190,7 +190,7 @@ impl MockDistServer { } // Returns the hash of the tarball - #[cfg_attr(feature = "otel", tracing::instrument(skip_all, fields(format=%format)))] + #[tracing::instrument(level = "trace", skip_all, fields(format=%format))] fn build_target_package( &self, channel: &MockChannel, @@ -277,7 +277,7 @@ impl MockDistServer { } // The v1 manifest is just the directory listing of the rust tarballs - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] fn write_manifest_v1(&self, channel: &MockChannel) { let mut buf = String::new(); let package = channel.packages.iter().find(|p| p.name == "rust").unwrap(); @@ -306,7 +306,7 @@ impl MockDistServer { hard_link(&hash_path, archive_hash_path).unwrap(); } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] fn write_manifest_v2( &self, channel: &MockChannel, diff --git a/src/toolchain/distributable.rs b/src/toolchain/distributable.rs index 63b9d34fd93..9d7d46e412b 100644 --- a/src/toolchain/distributable.rs +++ b/src/toolchain/distributable.rs @@ -306,14 +306,14 @@ impl<'a> DistributableToolchain<'a> { } } - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) fn get_manifestation(&self) -> anyhow::Result { let prefix = InstallPrefix::from(self.toolchain.path()); Manifestation::open(prefix, self.desc.target.clone()) } /// Get the manifest associated with this distribution - #[cfg_attr(feature = "otel", tracing::instrument(skip_all))] + #[tracing::instrument(level = "trace", skip_all)] pub(crate) fn get_manifest(&self) -> anyhow::Result { self.get_manifestation()? .load_manifest() @@ -329,7 +329,7 @@ impl<'a> DistributableToolchain<'a> { InstallPrefix::from(self.toolchain.path().to_owned()).guess_v1_manifest() } - #[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))] + #[tracing::instrument(level = "trace", err, skip_all)] pub(crate) async fn install( cfg: &'a Cfg, desc: &'_ ToolchainDesc, @@ -359,7 +359,7 @@ impl<'a> DistributableToolchain<'a> { Ok((status, Self::new(cfg, desc.clone())?)) } - #[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))] + #[tracing::instrument(level = "trace", err, skip_all)] pub async fn install_if_not_installed( cfg: &'a Cfg, desc: &'a ToolchainDesc, @@ -377,7 +377,7 @@ impl<'a> DistributableToolchain<'a> { } } - #[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))] + #[tracing::instrument(level = "trace", err, skip_all)] pub(crate) async fn update( &mut self, components: &[&str], @@ -389,7 +389,7 @@ impl<'a> DistributableToolchain<'a> { } /// Update a toolchain with control over the channel behaviour - #[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))] + #[tracing::instrument(level = "trace", err, skip_all)] pub(crate) async fn update_extra( &mut self, components: &[&str], diff --git a/src/toolchain/toolchain.rs b/src/toolchain/toolchain.rs index b6260080e1e..13f9832648c 100644 --- a/src/toolchain/toolchain.rs +++ b/src/toolchain/toolchain.rs @@ -276,7 +276,7 @@ impl<'a> Toolchain<'a> { } /// Infallible function that describes the version of rustc in an installed distribution - #[cfg_attr(feature = "otel", tracing::instrument)] + #[tracing::instrument(level = "trace")] pub fn rustc_version(&self) -> String { // TODO: use create_command instead of manual construction! let rustc_path = self.binary_file("rustc");