server: more tracing and logging
This commit is contained in:
parent
bbcf52b006
commit
b8dfdabf8d
@ -9,7 +9,7 @@ use log::{error, info, warn};
|
|||||||
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
||||||
use memmap::MmapOptions;
|
use memmap::MmapOptions;
|
||||||
use sqlx::{types::Json, PgPool};
|
use sqlx::{types::Json, PgPool};
|
||||||
use tracing::instrument;
|
use tracing::{info_span, instrument};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
compute_offset_limit,
|
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
|
// Only process the first file path is multiple files have the same id
|
||||||
let path = files.iter().next().unwrap();
|
let path = files.iter().next().unwrap();
|
||||||
let file = File::open(&path)?;
|
let file = File::open(&path)?;
|
||||||
|
info!("parsing {path}");
|
||||||
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
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);
|
let (matched_rule, add_tags) = find_tags(&rules, &m.headers);
|
||||||
if matched_rule {
|
if matched_rule {
|
||||||
if dryrun {
|
if dryrun {
|
||||||
@ -1054,7 +1055,8 @@ pub async fn label_unprocessed(
|
|||||||
info!(" {tag}: {}", ids.len());
|
info!(" {tag}: {}", ids.len());
|
||||||
if !dryrun {
|
if !dryrun {
|
||||||
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
|
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());
|
info!("Removing {} distinct labels", rm_mutations.len());
|
||||||
@ -1062,7 +1064,8 @@ pub async fn label_unprocessed(
|
|||||||
info!(" {tag}: {}", ids.len());
|
info!(" {tag}: {}", ids.len());
|
||||||
if !dryrun {
|
if !dryrun {
|
||||||
let ids: Vec<_> = ids.iter().map(|s| s.as_str()).collect();
|
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))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user