Repository: vercel/next.js
Pull request: Turbopack: more tracing

**View the diff without whitespace changes**

Add a few more spans similar to the ones that Next has (I don't know where these gaps come from), there are no gaps in the verbose trace below:
`TURBOPACK_TRACING=turbopack`:

![Bildschirmfoto 2025-01-27 um 10 23 01](https://github.com/user-attachments/assets/c06c10b5-ec4c-499d-883f-44e227ef5aa1)

`TURBOPACK_TRACING=turbo-tasks`:
![Bildschirmfoto 2025-01-27 um 10 23 16](https://github.com/user-attachments/assets/64a23237-db35-47b4-9d3a-0a717e4b0cd5)


Closes PACK-4172

Changed files:
filename: turbopack/crates/turbopack-cli/src/build/mod.rs
patch: @@ -7,6 +7,7 @@ use std::{
 
 use anyhow::{bail, Context, Result};
 use rustc_hash::FxHashSet;
+use tracing::Instrument;
 use turbo_rcstr::RcStr;
 use turbo_tasks::{
     apply_effects, ReadConsistency, ResolvedVc, TransientInstance, TryJoinIterExt, TurboTasks,
@@ -149,7 +150,9 @@ impl TurbopackBuildBuilder {
             // Await the result to propagate any errors.
             build_result_op.read_strongly_consistent().await?;
 
-            apply_effects(build_result_op).await?;
+            apply_effects(build_result_op)
+                .instrument(tracing::info_span!("apply effects"))
+                .await?;
 
             let issue_reporter: Vc<Box<dyn IssueReporter>> =
                 Vc::upcast(ConsoleUi::new(TransientInstance::new(LogOptions {
@@ -270,26 +273,30 @@ async fn build_internal(
 
     let origin = PlainResolveOrigin::new(asset_context, project_fs.root().join("_".into()));
     let project_dir = &project_dir;
-    let entries = entry_requests
-        .into_iter()
-        .map(|request_vc| async move {
-            let ty = Value::new(ReferenceType::Entry(EntryReferenceSubType::Undefined));
-            let request = request_vc.await?;
-            origin
-                .resolve_asset(request_vc, origin.resolve_options(ty.clone()), ty)
-                .await?
-                .first_module()
-                .await?
-                .with_context(|| {
-                    format!(
-                        "Unable to resolve entry {} from directory {}.",
-                        request.request().unwrap(),
-                        project_dir
-                    )
-                })
-        })
-        .try_join()
-        .await?;
+    let entries = async move {
+        entry_requests
+            .into_iter()
+            .map(|request_vc| async move {
+                let ty = Value::new(ReferenceType::Entry(EntryReferenceSubType::Undefined));
+                let request = request_vc.await?;
+                origin
+                    .resolve_asset(request_vc, origin.resolve_options(ty.clone()), ty)
+                    .await?
+                    .first_module()
+                    .await?
+                    .with_context(|| {
+                        format!(
+                            "Unable to resolve entry {} from directory {}.",
+                            request.request().unwrap(),
+                            project_dir
+                        )
+                    })
+            })
+            .try_join()
+            .await
+    }
+    .instrument(tracing::info_span!("resolve entries"))
+    .await?;
 
     let module_graph =
         ModuleGraph::from_modules(Vc::cell(vec![ChunkGroupEntry::Entry(entries.clone())]));
@@ -445,7 +452,11 @@ async fn build_internal(
 
     let mut chunks: FxHashSet<ResolvedVc<Box<dyn OutputAsset>>> = FxHashSet::default();
     for chunk_group in entry_chunk_groups {
-        chunks.extend(&*all_assets_from_entries(*chunk_group).await?);
+        chunks.extend(
+            &*async move { all_assets_from_entries(*chunk_group).await }
+                .instrument(tracing::info_span!("list chunks"))
+                .await?,
+        );
     }
 
     chunks

filename: turbopack/crates/turbopack-ecmascript/src/minify.rs
patch: @@ -19,11 +19,13 @@ use swc_core::{
         transforms::base::fixer::paren_remover,
     },
 };
+use tracing::{instrument, Level};
 use turbo_tasks_fs::FileSystemPath;
 use turbopack_core::code_builder::{Code, CodeBuilder};
 
 use crate::parse::generate_js_source_map;
 
+#[instrument(level = Level::INFO, skip_all)]
 pub fn minify(path: &FileSystemPath, code: &Code, source_maps: bool, mangle: bool) -> Result<Code> {
     let source_maps = source_maps
         .then(|| code.generate_source_map_ref())