diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 74d3ddf76ac9..fc5896065605 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -16,6 +16,7 @@ use crate::util::is_rustup; use cargo::core::shell::ColorChoice; use cargo::util::style; +#[tracing::instrument(skip_all)] pub fn main(gctx: &mut GlobalContext) -> CliResult { // CAUTION: Be careful with using `config` until it is configured below. // In general, try to avoid loading config values unless necessary (like @@ -272,6 +273,7 @@ fn add_ssl(version_string: &mut String) { /// [`GlobalArgs`] need to be extracted before expanding aliases because the /// clap code for extracting a subcommand discards global options /// (appearing before the subcommand). +#[tracing::instrument(skip_all)] fn expand_aliases( gctx: &mut GlobalContext, args: ArgMatches, @@ -377,6 +379,7 @@ For more information, see issue #12207 CliResult { match self { Self::Builtin(exec) => exec(gctx, subcommand_args), @@ -530,6 +534,7 @@ impl GlobalArgs { } } +#[tracing::instrument(skip_all)] pub fn cli(gctx: &GlobalContext) -> Command { // Don't let config errors get in the way of parsing arguments let term = gctx.get::("term").unwrap_or_default(); diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index a84d300c498c..9845de4f7c86 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -287,6 +287,7 @@ fn search_directories(gctx: &GlobalContext) -> Vec { } /// Initialize libgit2. +#[tracing::instrument(skip_all)] fn init_git(gctx: &GlobalContext) { // Disabling the owner validation in git can, in theory, lead to code execution // vulnerabilities. However, libgit2 does not launch executables, which is the foundation of @@ -318,6 +319,7 @@ fn init_git(gctx: &GlobalContext) { /// If the user has a non-default network configuration, then libgit2 will be /// configured to use libcurl instead of the built-in networking support so /// that those configuration settings can be used. +#[tracing::instrument(skip_all)] fn init_git_transports(gctx: &GlobalContext) { match needs_custom_http_transport(gctx) { Ok(true) => {} diff --git a/src/cargo/core/compiler/build_runner/mod.rs b/src/cargo/core/compiler/build_runner/mod.rs index 1be9769ac299..aa101195d933 100644 --- a/src/cargo/core/compiler/build_runner/mod.rs +++ b/src/cargo/core/compiler/build_runner/mod.rs @@ -133,6 +133,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> { /// See [`ops::cargo_compile`] for a higher-level view of the compile process. /// /// [`ops::cargo_compile`]: ../../../ops/cargo_compile/index.html + #[tracing::instrument(skip_all)] pub fn compile(mut self, exec: &Arc) -> CargoResult> { // A shared lock is held during the duration of the build since rustc // needs to read from the `src` cache, and we don't want other @@ -324,6 +325,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> { .map(|output| output.bin_dst().clone())) } + #[tracing::instrument(skip_all)] pub fn prepare_units(&mut self) -> CargoResult<()> { let dest = self.bcx.profiles.get_dir_name(); let host_layout = Layout::new(self.bcx.ws, None, &dest)?; @@ -349,6 +351,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> { /// Prepare this context, ensuring that all filesystem directories are in /// place. + #[tracing::instrument(skip_all)] pub fn prepare(&mut self) -> CargoResult<()> { let _p = profile::start("preparing layout"); @@ -451,6 +454,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> { /// Check if any output file name collision happens. /// See for more. + #[tracing::instrument(skip_all)] fn check_collisions(&self) -> CargoResult<()> { let mut output_collisions = HashMap::new(); let describe_collision = |unit: &Unit, other_unit: &Unit, path: &PathBuf| -> String { @@ -633,6 +637,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> { /// If the current crate has reverse-dependencies, such a Check unit should exist, and so /// we use that crate's metadata. If not, we use the crate's Doc unit so at least examples /// scraped from the current crate can be used when documenting the current crate. + #[tracing::instrument(skip_all)] pub fn compute_metadata_for_doc_units(&mut self) { for unit in self.bcx.unit_graph.keys() { if !unit.mode.is_doc() && !unit.mode.is_doc_scrape() { diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 153ef3aa6660..e0f83f82f865 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -194,6 +194,7 @@ impl LinkArgTarget { } /// Prepares a `Work` that executes the target as a custom build script. +#[tracing::instrument(skip_all)] pub fn prepare(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResult { let _p = profile::start(format!( "build script prepare: {}/{}", diff --git a/src/cargo/core/compiler/fingerprint/mod.rs b/src/cargo/core/compiler/fingerprint/mod.rs index 477543b0b49c..902b80729916 100644 --- a/src/cargo/core/compiler/fingerprint/mod.rs +++ b/src/cargo/core/compiler/fingerprint/mod.rs @@ -399,6 +399,7 @@ pub use dirty_reason::DirtyReason; /// transitively propagate throughout the dependency graph, it only forces this /// one unit which is very unlikely to be what you want unless you're /// exclusively talking about top-level units. +#[tracing::instrument(skip(build_runner, unit))] pub fn prepare_target( build_runner: &mut BuildRunner<'_, '_>, unit: &Unit, diff --git a/src/cargo/core/compiler/job_queue/mod.rs b/src/cargo/core/compiler/job_queue/mod.rs index dc34c92a7ae4..563bcd52dc91 100644 --- a/src/cargo/core/compiler/job_queue/mod.rs +++ b/src/cargo/core/compiler/job_queue/mod.rs @@ -467,6 +467,7 @@ impl<'gctx> JobQueue<'gctx> { /// This function will spawn off `config.jobs()` workers to build all of the /// necessary dependencies, in order. Freshness is propagated as far as /// possible along each dependency chain. + #[tracing::instrument(skip_all)] pub fn execute( mut self, build_runner: &mut BuildRunner<'_, '_>, diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 31aa29f573b4..3cca4cb7f106 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -158,6 +158,7 @@ impl Executor for DefaultExecutor { /// Note that **no actual work is executed as part of this**, that's all done /// next as part of [`JobQueue::execute`] function which will run everything /// in order with proper parallelism. +#[tracing::instrument(skip(build_runner, jobs, plan, exec))] fn compile<'gctx>( build_runner: &mut BuildRunner<'_, 'gctx>, jobs: &mut JobQueue<'gctx>, diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs index 9040d40fabbd..72f47c6491f3 100644 --- a/src/cargo/core/compiler/unit_dependencies.rs +++ b/src/cargo/core/compiler/unit_dependencies.rs @@ -81,6 +81,7 @@ impl IsArtifact { /// Then entry point for building a dependency graph of compilation units. /// /// You can find some information for arguments from doc of [`State`]. +#[tracing::instrument(skip_all)] pub fn build_unit_dependencies<'a, 'gctx>( ws: &'a Workspace<'gctx>, package_set: &'a PackageSet<'gctx>, diff --git a/src/cargo/core/global_cache_tracker.rs b/src/cargo/core/global_cache_tracker.rs index 563723b77f15..bc6198a83621 100644 --- a/src/cargo/core/global_cache_tracker.rs +++ b/src/cargo/core/global_cache_tracker.rs @@ -546,6 +546,7 @@ impl GlobalCacheTracker { .with_context(|| "failed to clean entries from the global cache") } + #[tracing::instrument(skip_all)] fn clean_inner( &mut self, clean_ctx: &mut CleanContext<'_>, @@ -696,6 +697,7 @@ impl GlobalCacheTracker { /// /// These orphaned files will be added to `delete_paths` so that the /// caller can delete them. + #[tracing::instrument(skip_all)] fn sync_db_with_files( conn: &Connection, now: Timestamp, @@ -795,6 +797,7 @@ impl GlobalCacheTracker { } /// For parent tables, add any entries that are on disk but aren't tracked in the db. + #[tracing::instrument(skip_all)] fn update_parent_for_missing_from_db( conn: &Connection, now: Timestamp, @@ -822,6 +825,7 @@ impl GlobalCacheTracker { /// /// This could happen for example if the user manually deleted the file or /// any such scenario where the filesystem and db are out of sync. + #[tracing::instrument(skip_all)] fn update_db_for_removed( conn: &Connection, parent_table_name: &str, @@ -851,6 +855,7 @@ impl GlobalCacheTracker { } /// Removes database entries for any files that are not on disk for the parent tables. + #[tracing::instrument(skip_all)] fn update_db_parent_for_removed_from_disk( conn: &Connection, parent_table_name: &str, @@ -888,6 +893,7 @@ impl GlobalCacheTracker { /// Updates the database to add any `.crate` files that are currently /// not tracked (such as when they are downloaded by an older version of /// cargo). + #[tracing::instrument(skip_all)] fn populate_untracked_crate( conn: &Connection, now: Timestamp, @@ -922,6 +928,7 @@ impl GlobalCacheTracker { /// Updates the database to add any files that are currently not tracked /// (such as when they are downloaded by an older version of cargo). + #[tracing::instrument(skip_all)] fn populate_untracked( conn: &Connection, now: Timestamp, @@ -987,6 +994,7 @@ impl GlobalCacheTracker { /// size. /// /// `update_db_for_removed` should be called before this is called. + #[tracing::instrument(skip_all)] fn update_null_sizes( conn: &Connection, gctx: &GlobalContext, @@ -1560,6 +1568,7 @@ impl DeferredGlobalLastUse { /// Saves all of the deferred information to the database. /// /// This will also clear the state of `self`. + #[tracing::instrument(skip_all)] pub fn save(&mut self, tracker: &mut GlobalCacheTracker) -> CargoResult<()> { let _p = crate::util::profile::start("saving last-use data"); trace!(target: "gc", "saving last-use data"); diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index e5ba3a9b369c..d9151e1a9a6b 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -497,6 +497,7 @@ impl<'gctx> PackageSet<'gctx> { } /// Downloads any packages accessible from the give root ids. + #[tracing::instrument(skip_all)] pub fn download_accessible( &self, resolve: &Resolve, diff --git a/src/cargo/core/resolver/features.rs b/src/cargo/core/resolver/features.rs index 7bf944b75552..85b0a112a8e0 100644 --- a/src/cargo/core/resolver/features.rs +++ b/src/cargo/core/resolver/features.rs @@ -444,6 +444,7 @@ pub struct FeatureResolver<'a, 'gctx> { impl<'a, 'gctx> FeatureResolver<'a, 'gctx> { /// Runs the resolution algorithm and returns a new [`ResolvedFeatures`] /// with the result. + #[tracing::instrument(skip_all)] pub fn resolve( ws: &Workspace<'gctx>, target_data: &'a mut RustcTargetData<'gctx>, diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index c351ed0fe8ad..2c3ee3afb509 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -122,6 +122,7 @@ mod version_prefs; /// /// * `config` - a location to print warnings and such, or `None` if no warnings /// should be printed +#[tracing::instrument(skip_all)] pub fn resolve( summaries: &[(Summary, ResolveOpts)], replacements: &[(PackageIdSpec, Dependency)], diff --git a/src/cargo/ops/cargo_compile/mod.rs b/src/cargo/ops/cargo_compile/mod.rs index 081e9825369a..e8b3c53f683f 100644 --- a/src/cargo/ops/cargo_compile/mod.rs +++ b/src/cargo/ops/cargo_compile/mod.rs @@ -142,6 +142,7 @@ pub fn compile_with_exec<'a>( } /// Like [`compile_with_exec`] but without warnings from manifest parsing. +#[tracing::instrument(skip_all)] pub fn compile_ws<'a>( ws: &Workspace<'a>, options: &CompileOptions, @@ -197,6 +198,7 @@ pub fn print<'a>( /// /// For how it works and what data it collects, /// please see the [module-level documentation](self). +#[tracing::instrument(skip_all)] pub fn create_bcx<'a, 'gctx>( ws: &'a Workspace<'gctx>, options: &'a CompileOptions, diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs index a5547f608df9..8b7569be7be4 100644 --- a/src/cargo/ops/lockfile.rs +++ b/src/cargo/ops/lockfile.rs @@ -6,6 +6,7 @@ use crate::util::Filesystem; use anyhow::Context as _; +#[tracing::instrument(skip_all)] pub fn load_pkg_lockfile(ws: &Workspace<'_>) -> CargoResult> { let lock_root = lock_root(ws); if !lock_root.as_path_unlocked().join("Cargo.lock").exists() { @@ -32,6 +33,7 @@ pub fn resolve_to_string(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoResu Ok(out) } +#[tracing::instrument(skip_all)] pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoResult<()> { let (orig, mut out, lock_root) = resolve_to_string_orig(ws, resolve); diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index 875edcb7e6b9..98d1ba0dfca0 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -234,6 +234,7 @@ pub fn resolve_ws_with_opts<'gctx>( }) } +#[tracing::instrument(skip_all)] fn resolve_with_registry<'gctx>( ws: &Workspace<'gctx>, registry: &mut PackageRegistry<'gctx>, @@ -271,6 +272,7 @@ fn resolve_with_registry<'gctx>( /// /// If `register_patches` is true, then entries from the `[patch]` table in /// the manifest will be added to the given `PackageRegistry`. +#[tracing::instrument(skip_all)] pub fn resolve_with_previous<'gctx>( registry: &mut PackageRegistry<'gctx>, ws: &Workspace<'gctx>, @@ -529,6 +531,7 @@ pub fn resolve_with_previous<'gctx>( /// Read the `paths` configuration variable to discover all path overrides that /// have been configured. +#[tracing::instrument(skip_all)] pub fn add_overrides<'a>( registry: &mut PackageRegistry<'a>, ws: &Workspace<'a>, diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 9fb542ee0ea6..6996136602f1 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -500,6 +500,7 @@ pub trait ArgMatchesExt { root_manifest(self._value_of("manifest-path").map(Path::new), gctx) } + #[tracing::instrument(skip_all)] fn workspace<'a>(&self, gctx: &'a GlobalContext) -> CargoResult> { let root = self.root_manifest(gctx)?; let mut ws = Workspace::new(&root, gctx)?; diff --git a/src/cargo/util/context/mod.rs b/src/cargo/util/context/mod.rs index c64458990f4d..3fc91dd1ef4b 100644 --- a/src/cargo/util/context/mod.rs +++ b/src/cargo/util/context/mod.rs @@ -1945,6 +1945,7 @@ impl GlobalContext { /// Locks are usually acquired via [`GlobalContext::acquire_package_cache_lock`] /// or [`GlobalContext::try_acquire_package_cache_lock`]. #[track_caller] + #[tracing::instrument(skip_all)] pub fn assert_package_cache_locked<'a>( &self, mode: CacheLockMode, @@ -1965,6 +1966,7 @@ impl GlobalContext { /// /// See [`crate::util::cache_lock`] for an in-depth discussion of locking /// and lock modes. + #[tracing::instrument(skip_all)] pub fn acquire_package_cache_lock(&self, mode: CacheLockMode) -> CargoResult> { self.package_cache_lock.lock(self, mode) } @@ -1974,6 +1976,7 @@ impl GlobalContext { /// /// See [`crate::util::cache_lock`] for an in-depth discussion of locking /// and lock modes. + #[tracing::instrument(skip_all)] pub fn try_acquire_package_cache_lock( &self, mode: CacheLockMode, diff --git a/src/cargo/util/rustc.rs b/src/cargo/util/rustc.rs index 158c14363b03..4d4c328a0b3d 100644 --- a/src/cargo/util/rustc.rs +++ b/src/cargo/util/rustc.rs @@ -39,6 +39,7 @@ impl Rustc { /// /// If successful this function returns a description of the compiler along /// with a list of its capabilities. + #[tracing::instrument(skip(gctx))] pub fn new( path: PathBuf, wrapper: Option, diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 1f10d37d334c..a11d10beeb8c 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -44,6 +44,7 @@ use self::targets::targets; /// within the manifest. For virtual manifests, these paths can only /// come from patched or replaced dependencies. These paths are not /// canonicalized. +#[tracing::instrument(skip(gctx))] pub fn read_manifest( path: &Path, source_id: SourceId,