Skip to content

Commit 1b7662e

Browse files
committed
Revert 1 commits
0cf0c6b 'feat(log): unhide `tracing::instrument` from behind `feature = "otel"`'
1 parent 0cf0c6b commit 1b7662e

File tree

18 files changed

+38
-37
lines changed

18 files changed

+38
-37
lines changed

doc/dev-guide/src/tracing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ when enabled. Instrumenting a currently uninstrumented function is mostly simply
5252
done like so:
5353

5454
```rust
55-
#[tracing::instrument(level = "trace", err, skip_all)]
55+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
5656
```
5757

5858
`skip_all` is not required, but some core structs don't implement Debug yet, and

rustup-macros/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn test_inner(mod_path: String, mut input: ItemFn) -> syn::Result<TokenStream> {
9898
#before_ident().await;
9999
// Define a function with same name we can instrument inside the
100100
// tracing enablement logic.
101-
#[tracing::instrument(level = "trace", skip_all)]
101+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
102102
async fn #name() { #inner }
103103
// Thunk through a new thread to permit catching the panic
104104
// without grabbing the entire state machine defined by the

src/bin/rustup-init.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ async fn maybe_trace_rustup() -> Result<utils::ExitCode> {
6767
result
6868
}
6969

70-
#[tracing::instrument(level = "trace")]
70+
// FIXME: Make `tracing::instrument` always run
71+
#[cfg_attr(feature = "otel", tracing::instrument)]
7172
async fn run_rustup() -> Result<utils::ExitCode> {
7273
if let Ok(dir) = process().var("RUSTUP_TRACE_DIR") {
7374
open_trace_file!(dir)?;
@@ -79,7 +80,7 @@ async fn run_rustup() -> Result<utils::ExitCode> {
7980
result
8081
}
8182

82-
#[tracing::instrument(level = "trace", err)]
83+
#[cfg_attr(feature = "otel", tracing::instrument(err))]
8384
async fn run_rustup_inner() -> Result<utils::ExitCode> {
8485
// Guard against infinite proxy recursion. This mostly happens due to
8586
// bugs in rustup.

src/cli/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl Notifier {
179179
}
180180
}
181181

182-
#[tracing::instrument(level = "trace")]
182+
#[cfg_attr(feature = "otel", tracing::instrument)]
183183
pub(crate) fn set_globals(current_dir: PathBuf, verbose: bool, quiet: bool) -> Result<Cfg> {
184184
let notifier = Notifier::new(verbose, quiet);
185185
Cfg::from_env(current_dir, Arc::new(move |n| notifier.handle(n)))

src/cli/proxy_mode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
toolchain::names::ResolvableLocalToolchainName,
1111
};
1212

13-
#[tracing::instrument(level = "trace")]
13+
#[cfg_attr(feature = "otel", tracing::instrument)]
1414
pub async fn main(arg0: &str, current_dir: PathBuf) -> Result<ExitStatus> {
1515
self_update::cleanup_self_updater()?;
1616

src/cli/rustup_mode.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ enum SetSubcmd {
535535
},
536536
}
537537

538-
#[tracing::instrument(level = "trace", fields(args = format!("{:?}", process().args_os().collect::<Vec<_>>())))]
538+
#[cfg_attr(feature = "otel", tracing::instrument(fields(args = format!("{:?}", process().args_os().collect::<Vec<_>>()))))]
539539
pub async fn main(current_dir: PathBuf) -> Result<utils::ExitCode> {
540540
self_update::cleanup_self_updater()?;
541541

@@ -550,7 +550,7 @@ pub async fn main(current_dir: PathBuf) -> Result<utils::ExitCode> {
550550
write!(process().stdout().lock(), "{err}")?;
551551
info!("This is the version for the rustup toolchain manager, not the rustc compiler.");
552552

553-
#[tracing::instrument(level = "trace")]
553+
#[cfg_attr(feature = "otel", tracing::instrument)]
554554
async fn rustc_version(
555555
current_dir: PathBuf,
556556
) -> std::result::Result<String, Box<dyn std::error::Error>> {
@@ -938,7 +938,7 @@ async fn which(
938938
Ok(utils::ExitCode(0))
939939
}
940940

941-
#[tracing::instrument(level = "trace", skip_all)]
941+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
942942
fn show(cfg: &Cfg, verbose: bool) -> Result<utils::ExitCode> {
943943
common::warn_if_host_is_emulated();
944944

@@ -1075,7 +1075,7 @@ fn show(cfg: &Cfg, verbose: bool) -> Result<utils::ExitCode> {
10751075
Ok(utils::ExitCode(0))
10761076
}
10771077

1078-
#[tracing::instrument(level = "trace", skip_all)]
1078+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
10791079
fn show_active_toolchain(cfg: &Cfg, verbose: bool) -> Result<utils::ExitCode> {
10801080
match cfg.find_active_toolchain()? {
10811081
Some((toolchain_name, reason)) => {
@@ -1099,7 +1099,7 @@ fn show_active_toolchain(cfg: &Cfg, verbose: bool) -> Result<utils::ExitCode> {
10991099
Ok(utils::ExitCode(0))
11001100
}
11011101

1102-
#[tracing::instrument(level = "trace", skip_all)]
1102+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
11031103
fn show_rustup_home(cfg: &Cfg) -> Result<utils::ExitCode> {
11041104
writeln!(process().stdout().lock(), "{}", cfg.rustup_dir.display())?;
11051105
Ok(utils::ExitCode(0))

src/cli/self_update.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ pub(crate) async fn check_rustup_update() -> Result<()> {
13211321
Ok(())
13221322
}
13231323

1324-
#[tracing::instrument(level = "trace")]
1324+
#[cfg_attr(feature = "otel", tracing::instrument)]
13251325
pub(crate) fn cleanup_self_updater() -> Result<()> {
13261326
let cargo_home = utils::cargo_home()?;
13271327
let setup = cargo_home.join(format!("bin/rustup-init{EXE_SUFFIX}"));

src/cli/self_update/windows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ fn has_windows_sdk_libs() -> bool {
264264
}
265265

266266
/// Run by rustup-gc-$num.exe to delete CARGO_HOME
267-
#[tracing::instrument(level = "trace")]
267+
#[cfg_attr(feature = "otel", tracing::instrument)]
268268
pub fn complete_windows_uninstall() -> Result<utils::ExitCode> {
269269
use std::process::Stdio;
270270

src/cli/setup_mode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ struct RustupInit {
7575
dump_testament: bool,
7676
}
7777

78-
#[tracing::instrument(level = "trace")]
78+
#[cfg_attr(feature = "otel", tracing::instrument)]
7979
pub async fn main(current_dir: PathBuf) -> Result<utils::ExitCode> {
8080
use clap::error::ErrorKind;
8181

src/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anyhow::{Context, Result};
99

1010
use crate::errors::*;
1111

12-
#[tracing::instrument(level = "trace", err)]
12+
#[cfg_attr(feature = "otel", tracing::instrument(err))]
1313
pub(crate) fn run_command_for_dir<S: AsRef<OsStr> + Debug>(
1414
mut cmd: Command,
1515
arg0: &str,

src/config.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ impl Cfg {
456456
Ok(self.update_hash_dir.join(toolchain.to_string()))
457457
}
458458

459-
#[tracing::instrument(level = "trace", skip_all)]
459+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
460460
pub(crate) fn upgrade_data(&self) -> Result<()> {
461461
let current_version = self.settings_file.with(|s| Ok(s.version))?;
462462
if current_version == MetadataVersion::default() {
@@ -693,7 +693,7 @@ impl Cfg {
693693
.ok_or_else(no_toolchain_error)
694694
}
695695

696-
#[tracing::instrument(level = "trace", skip_all)]
696+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
697697
pub(crate) async fn maybe_find_or_install_active_toolchain(
698698
&self,
699699
path: &Path,
@@ -801,7 +801,7 @@ impl Cfg {
801801
/// - not files
802802
/// - named with a valid resolved toolchain name
803803
/// Currently no notification of incorrect names or entry type is done.
804-
#[tracing::instrument(level = "trace", skip_all)]
804+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
805805
pub(crate) fn list_toolchains(&self) -> Result<Vec<ToolchainName>> {
806806
if utils::is_directory(&self.toolchains_dir) {
807807
let mut toolchains: Vec<_> = utils::read_dir("toolchains", &self.toolchains_dir)?
@@ -871,7 +871,7 @@ impl Cfg {
871871
Ok(channels.collect().await)
872872
}
873873

874-
#[tracing::instrument(level = "trace", skip_all)]
874+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
875875
pub(crate) fn check_metadata_version(&self) -> Result<()> {
876876
utils::assert_is_directory(&self.rustup_dir)?;
877877

@@ -899,7 +899,7 @@ impl Cfg {
899899
})
900900
}
901901

902-
#[tracing::instrument(level = "trace", skip_all)]
902+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
903903
pub(crate) fn get_default_host_triple(&self) -> Result<dist::TargetTriple> {
904904
self.settings_file.with(|s| Ok(get_default_host_triple(s)))
905905
}

src/dist/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ pub(crate) fn valid_profile_names() -> String {
701701
// an upgrade then all the existing components will be upgraded.
702702
//
703703
// Returns the manifest's hash if anything changed.
704-
#[tracing::instrument(level = "trace", err, skip_all, fields(profile=format!("{profile:?}"), prefix=prefix.path().to_string_lossy().to_string()))]
704+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all, fields(profile=format!("{profile:?}"), prefix=prefix.path().to_string_lossy().to_string())))]
705705
pub(crate) async fn update_from_dist(
706706
download: DownloadCfg<'_>,
707707
update_hash: Option<&Path>,

src/dist/manifestation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl Manifestation {
376376
}
377377
}
378378

379-
#[tracing::instrument(level = "trace")]
379+
#[cfg_attr(feature = "otel", tracing::instrument)]
380380
pub fn load_manifest(&self) -> Result<Option<Manifest>> {
381381
let prefix = self.installation.prefix();
382382
let old_manifest_path = prefix.manifest_file(DIST_MANIFEST);

src/install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) enum InstallMethod<'a> {
5858

5959
impl<'a> InstallMethod<'a> {
6060
// Install a toolchain
61-
#[tracing::instrument(level = "trace", err, skip_all)]
61+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
6262
pub(crate) async fn install(&self) -> Result<UpdateStatus> {
6363
let nh = self.cfg().notify_handler.clone();
6464
match self {

src/test/mock/clitools.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ impl Release {
902902
}
903903
}
904904

905-
#[tracing::instrument(level = "trace", skip_all)]
905+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
906906
fn link(&self, path: &Path) {
907907
// Also create the manifests for releases by version
908908
let _ = hard_link(
@@ -955,7 +955,7 @@ impl Release {
955955
}
956956

957957
// Creates a mock dist server populated with some test data
958-
#[tracing::instrument(level = "trace", skip_all)]
958+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
959959
fn create_mock_dist_server(path: &Path, s: Scenario) {
960960
let chans = match s {
961961
Scenario::None => return,

src/test/mock/dist.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub enum MockManifestVersion {
130130
}
131131

132132
impl MockDistServer {
133-
#[tracing::instrument(level = "trace", skip_all)]
133+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
134134
pub fn write(&self, vs: &[MockManifestVersion], enable_xz: bool, enable_zst: bool) {
135135
fs::create_dir_all(&self.path).unwrap();
136136

@@ -149,7 +149,7 @@ impl MockDistServer {
149149
}
150150
}
151151

152-
#[tracing::instrument(level = "trace", skip_all)]
152+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
153153
fn build_package(
154154
&self,
155155
channel: &MockChannel,
@@ -190,7 +190,7 @@ impl MockDistServer {
190190
}
191191

192192
// Returns the hash of the tarball
193-
#[tracing::instrument(level = "trace", skip_all, fields(format=%format))]
193+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all, fields(format=%format)))]
194194
fn build_target_package(
195195
&self,
196196
channel: &MockChannel,
@@ -277,7 +277,7 @@ impl MockDistServer {
277277
}
278278

279279
// The v1 manifest is just the directory listing of the rust tarballs
280-
#[tracing::instrument(level = "trace", skip_all)]
280+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
281281
fn write_manifest_v1(&self, channel: &MockChannel) {
282282
let mut buf = String::new();
283283
let package = channel.packages.iter().find(|p| p.name == "rust").unwrap();
@@ -306,7 +306,7 @@ impl MockDistServer {
306306
hard_link(&hash_path, archive_hash_path).unwrap();
307307
}
308308

309-
#[tracing::instrument(level = "trace", skip_all)]
309+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
310310
fn write_manifest_v2(
311311
&self,
312312
channel: &MockChannel,

src/toolchain/distributable.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ impl<'a> DistributableToolchain<'a> {
306306
}
307307
}
308308

309-
#[tracing::instrument(level = "trace", skip_all)]
309+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
310310
pub(crate) fn get_manifestation(&self) -> anyhow::Result<Manifestation> {
311311
let prefix = InstallPrefix::from(self.toolchain.path());
312312
Manifestation::open(prefix, self.desc.target.clone())
313313
}
314314

315315
/// Get the manifest associated with this distribution
316-
#[tracing::instrument(level = "trace", skip_all)]
316+
#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
317317
pub(crate) fn get_manifest(&self) -> anyhow::Result<Manifest> {
318318
self.get_manifestation()?
319319
.load_manifest()
@@ -329,7 +329,7 @@ impl<'a> DistributableToolchain<'a> {
329329
InstallPrefix::from(self.toolchain.path().to_owned()).guess_v1_manifest()
330330
}
331331

332-
#[tracing::instrument(level = "trace", err, skip_all)]
332+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
333333
pub(crate) async fn install(
334334
cfg: &'a Cfg,
335335
desc: &'_ ToolchainDesc,
@@ -359,7 +359,7 @@ impl<'a> DistributableToolchain<'a> {
359359
Ok((status, Self::new(cfg, desc.clone())?))
360360
}
361361

362-
#[tracing::instrument(level = "trace", err, skip_all)]
362+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
363363
pub async fn install_if_not_installed(
364364
cfg: &'a Cfg,
365365
desc: &'a ToolchainDesc,
@@ -377,7 +377,7 @@ impl<'a> DistributableToolchain<'a> {
377377
}
378378
}
379379

380-
#[tracing::instrument(level = "trace", err, skip_all)]
380+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
381381
pub(crate) async fn update(
382382
&mut self,
383383
components: &[&str],
@@ -389,7 +389,7 @@ impl<'a> DistributableToolchain<'a> {
389389
}
390390

391391
/// Update a toolchain with control over the channel behaviour
392-
#[tracing::instrument(level = "trace", err, skip_all)]
392+
#[cfg_attr(feature = "otel", tracing::instrument(err, skip_all))]
393393
pub(crate) async fn update_extra(
394394
&mut self,
395395
components: &[&str],

src/toolchain/toolchain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl<'a> Toolchain<'a> {
276276
}
277277

278278
/// Infallible function that describes the version of rustc in an installed distribution
279-
#[tracing::instrument(level = "trace")]
279+
#[cfg_attr(feature = "otel", tracing::instrument)]
280280
pub fn rustc_version(&self) -> String {
281281
// TODO: use create_command instead of manual construction!
282282
let rustc_path = self.binary_file("rustc");

0 commit comments

Comments
 (0)