git: Annotate more functions and blocks with tracing spans (#46642)

Jakub Konka created

Release Notes:

- N/A

Change summary

Cargo.lock                     |  1 +
crates/editor/src/git/blame.rs |  3 +++
crates/git/Cargo.toml          |  1 +
crates/git/src/blame.rs        | 28 ++++++++++++++++------------
4 files changed, 21 insertions(+), 12 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -7095,6 +7095,7 @@ dependencies = [
  "urlencoding",
  "util",
  "uuid",
+ "ztracing",
 ]
 
 [[package]]

crates/editor/src/git/blame.rs 🔗

@@ -489,6 +489,7 @@ impl GitBlame {
         }
     }
 
+    #[ztracing::instrument(skip_all)]
     fn generate(&mut self, cx: &mut Context<Self>) {
         if !self.focused {
             self.changed_while_blurred = true;
@@ -511,6 +512,8 @@ impl GitBlame {
             let mut all_errors = Vec::new();
 
             for buffers in buffers_to_blame.chunks(4) {
+                let span = ztracing::debug_span!("for each chunk of buffers");
+                let _enter = span.enter();
                 let blame = cx.update(|cx| {
                     buffers
                         .iter()

crates/git/Cargo.toml 🔗

@@ -41,6 +41,7 @@ urlencoding.workspace = true
 util.workspace = true
 uuid.workspace = true
 futures.workspace = true
+ztracing.workspace = true
 
 [dev-dependencies]
 pretty_assertions.workspace = true

crates/git/src/blame.rs 🔗

@@ -58,18 +58,22 @@ async fn run_git_blame(
     contents: &Rope,
     line_ending: LineEnding,
 ) -> Result<String> {
-    let mut child = util::command::new_smol_command(git_binary)
-        .current_dir(working_directory)
-        .arg("blame")
-        .arg("--incremental")
-        .arg("--contents")
-        .arg("-")
-        .arg(path.as_unix_str())
-        .stdin(Stdio::piped())
-        .stdout(Stdio::piped())
-        .stderr(Stdio::piped())
-        .spawn()
-        .context("starting git blame process")?;
+    let mut child = {
+        let span = ztracing::debug_span!("spawning git-blame command", path = path.as_unix_str());
+        let _enter = span.enter();
+        util::command::new_smol_command(git_binary)
+            .current_dir(working_directory)
+            .arg("blame")
+            .arg("--incremental")
+            .arg("--contents")
+            .arg("-")
+            .arg(path.as_unix_str())
+            .stdin(Stdio::piped())
+            .stdout(Stdio::piped())
+            .stderr(Stdio::piped())
+            .spawn()
+            .context("starting git blame process")?
+    };
 
     let stdin = child
         .stdin