diff --git a/server/src/nm.rs b/server/src/nm.rs index b6911d4..040dc94 100644 --- a/server/src/nm.rs +++ b/server/src/nm.rs @@ -9,7 +9,7 @@ use log::{error, info, warn}; use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail}; use memmap::MmapOptions; use sqlx::{types::Json, PgPool}; -use tracing::instrument; +use tracing::{info_span, instrument}; use crate::{ compute_offset_limit, @@ -990,8 +990,9 @@ pub async fn label_unprocessed( // Only process the first file path is multiple files have the same id let path = files.iter().next().unwrap(); let file = File::open(&path)?; + info!("parsing {path}"); let mmap = unsafe { MmapOptions::new().map(&file)? }; - let m = parse_mail(&mmap)?; + let m = info_span!("parse_mail", path = path).in_scope(|| parse_mail(&mmap))?; let (matched_rule, add_tags) = find_tags(&rules, &m.headers); if matched_rule { if dryrun { @@ -1054,7 +1055,8 @@ pub async fn label_unprocessed( info!(" {tag}: {}", ids.len()); if !dryrun { let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect(); - nm.tags_add(tag, &ids)?; + info_span!("tags_add", tag = tag, count = ids.len()) + .in_scope(|| nm.tags_add(tag, &ids))?; } } info!("Removing {} distinct labels", rm_mutations.len()); @@ -1062,7 +1064,8 @@ pub async fn label_unprocessed( info!(" {tag}: {}", ids.len()); if !dryrun { let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect(); - nm.tags_remove(tag, &ids)?; + info_span!("tags_remove", tag = tag, count = ids.len()) + .in_scope(|| nm.tags_remove(tag, &ids))?; } }