Skip to content

Commit

Permalink
feat(log): unhide tracing::instrument from behind feature = "otel"
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Jul 10, 2024
1 parent 2990d7a commit 2ede7f7
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion doc/dev-guide/src/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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
Expand Down
4 changes: 2 additions & 2 deletions src/bin/rustup-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async fn main() -> Result<ExitCode> {
}
}

#[cfg_attr(feature = "otel", tracing::instrument)]
#[tracing::instrument(level = "trace")]
async fn run_rustup(
process: &Process,
console_filter: Handle<EnvFilter, Registry>,
Expand All @@ -76,7 +76,7 @@ async fn run_rustup(
result
}

#[cfg_attr(feature = "otel", tracing::instrument(err))]
#[tracing::instrument(level = "trace", err)]
async fn run_rustup_inner(
process: &Process,
console_filter: Handle<EnvFilter, Registry>,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Notifier {
}
}

#[cfg_attr(feature = "otel", tracing::instrument)]
#[tracing::instrument(level = "trace")]
pub(crate) fn set_globals(
current_dir: PathBuf,
verbose: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/proxy_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
toolchain::ResolvableLocalToolchainName,
};

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

Expand Down
8 changes: 4 additions & 4 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ enum SetSubcmd {
},
}

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

Expand Down Expand Up @@ -907,7 +907,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<utils::ExitCode> {
common::warn_if_host_is_emulated(cfg.process);

Expand Down Expand Up @@ -1048,7 +1048,7 @@ fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode> {
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<utils::ExitCode> {
match cfg.find_active_toolchain()? {
Some((toolchain_name, reason)) => {
Expand All @@ -1075,7 +1075,7 @@ fn show_active_toolchain(cfg: &Cfg<'_>, verbose: bool) -> Result<utils::ExitCode
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<utils::ExitCode> {
writeln!(cfg.process.stdout().lock(), "{}", cfg.rustup_dir.display())?;
Ok(utils::ExitCode(0))
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ pub(crate) async fn check_rustup_update(process: &Process) -> Result<()> {
Ok(())
}

#[cfg_attr(feature = "otel", tracing::instrument)]
#[tracing::instrument(level = "trace")]
pub(crate) fn cleanup_self_updater(process: &Process) -> Result<()> {
let cargo_home = process.cargo_home()?;
let setup = cargo_home.join(format!("bin/rustup-init{EXE_SUFFIX}"));
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ fn has_windows_sdk_libs(process: &Process) -> 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(process: &Process) -> Result<utils::ExitCode> {
use std::process::Stdio;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct RustupInit {
dump_testament: bool,
}

#[cfg_attr(feature = "otel", tracing::instrument)]
#[tracing::instrument(level = "trace")]
pub async fn main(
current_dir: PathBuf,
process: &Process,
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S: AsRef<OsStr> + Debug>(
mut cmd: Command,
arg0: &str,
Expand Down
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ impl<'a> Cfg<'a> {
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() {
Expand Down Expand Up @@ -693,7 +693,7 @@ impl<'a> Cfg<'a> {
}
}

#[cfg_attr(feature = "otel", tracing::instrument)]
#[tracing::instrument(level = "trace")]
pub(crate) async fn active_rustc_version(&mut self) -> Result<String> {
if let Some(t) = self.process.args().find(|x| x.starts_with('+')) {
trace!("Fetching rustc version from toolchain `{}`", t);
Expand Down Expand Up @@ -734,7 +734,7 @@ impl<'a> Cfg<'a> {
})
}

#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
#[tracing::instrument(level = "trace", skip_all)]
async fn find_or_install_active_toolchain(&'a self) -> Result<(Toolchain<'a>, ActiveReason)> {
match self.find_override_config()? {
Some((override_config, reason)) => match override_config {
Expand Down Expand Up @@ -839,7 +839,7 @@ impl<'a> Cfg<'a> {
/// - 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<Vec<ToolchainName>> {
if utils::is_directory(&self.toolchains_dir) {
let mut toolchains: Vec<_> = utils::read_dir("toolchains", &self.toolchains_dir)?
Expand Down Expand Up @@ -921,7 +921,7 @@ impl<'a> Cfg<'a> {
})
}

#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
#[tracing::instrument(level = "trace", skip_all)]
pub(crate) fn get_default_host_triple(&self) -> Result<dist::TargetTriple> {
self.settings_file
.with(|s| Ok(get_default_host_triple(s, self.process)))
Expand Down
2 changes: 1 addition & 1 deletion src/dist/manifestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ impl Manifestation {
}
}

#[cfg_attr(feature = "otel", tracing::instrument)]
#[tracing::instrument(level = "trace")]
pub fn load_manifest(&self) -> Result<Option<Manifest>> {
let prefix = self.installation.prefix();
let old_manifest_path = prefix.manifest_file(DIST_MANIFEST);
Expand Down
2 changes: 1 addition & 1 deletion src/dist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ pub(crate) struct DistOptions<'a> {
// 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!("{:?}", opts.profile), prefix=prefix.path().to_string_lossy().to_string())))]
#[tracing::instrument(level = "trace", err, skip_all, fields(profile=format!("{:?}", opts.profile), prefix=prefix.path().to_string_lossy().to_string()))]
pub(crate) async fn update_from_dist(
prefix: &InstallPrefix,
opts: &DistOptions<'_>,
Expand Down
2 changes: 1 addition & 1 deletion src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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<UpdateStatus> {
let nh = &self.cfg().notify_handler;
match self {
Expand Down
6 changes: 3 additions & 3 deletions src/test/mock/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ impl Config {
output
}

#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
#[tracing::instrument(level = "trace", skip_all)]
pub(crate) async fn run_inprocess<I, A>(
&self,
name: &str,
Expand Down Expand Up @@ -1059,7 +1059,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(
Expand Down Expand Up @@ -1112,7 +1112,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,
Expand Down
10 changes: 5 additions & 5 deletions src/test/mock/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,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();

Expand All @@ -151,7 +151,7 @@ impl MockDistServer {
}
}

#[cfg_attr(feature = "otel", tracing::instrument(skip_all))]
#[tracing::instrument(level = "trace", skip_all)]
fn build_package(
&self,
channel: &MockChannel,
Expand Down Expand Up @@ -192,7 +192,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,
Expand Down Expand Up @@ -279,7 +279,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();
Expand Down Expand Up @@ -308,7 +308,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,
Expand Down
2 changes: 1 addition & 1 deletion src/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,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 {
match self.create_command("rustc") {
Ok(mut cmd) => {
Expand Down
12 changes: 6 additions & 6 deletions src/toolchain/distributable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,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<Manifestation> {
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<Manifest> {
self.get_manifestation()?
.load_manifest()
Expand All @@ -324,7 +324,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<'a>,
toolchain: &ToolchainDesc,
Expand Down Expand Up @@ -354,7 +354,7 @@ impl<'a> DistributableToolchain<'a> {
Ok((status, Self::new(cfg, toolchain.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<'a>,
desc: &ToolchainDesc,
Expand All @@ -372,7 +372,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],
Expand All @@ -384,7 +384,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],
Expand Down

0 comments on commit 2ede7f7

Please sign in to comment.