Add tracing to EXIF DAO methods

This commit is contained in:
Cameron
2025-12-23 22:57:24 -05:00
parent 636701a69e
commit c035678162
7 changed files with 306 additions and 175 deletions

View File

@@ -3,6 +3,7 @@ use std::sync::{Arc, Mutex};
use chrono::Utc;
use clap::Parser;
use opentelemetry;
use rayon::prelude::*;
use walkdir::WalkDir;
@@ -63,6 +64,9 @@ fn main() -> anyhow::Result<()> {
let results: Vec<_> = image_files
.par_iter()
.map(|path| {
// Create context for this processing iteration
let context = opentelemetry::Context::new();
let relative_path = match path.strip_prefix(&base) {
Ok(p) => p.to_str().unwrap().to_string(),
Err(_) => {
@@ -76,7 +80,7 @@ fn main() -> anyhow::Result<()> {
// Check if EXIF data already exists
let existing = if let Ok(mut dao_lock) = dao.lock() {
dao_lock.get_exif(&relative_path).ok().flatten()
dao_lock.get_exif(&context, &relative_path).ok().flatten()
} else {
eprintln!("{} - Failed to acquire database lock", relative_path);
return Err(anyhow::anyhow!("Lock error"));
@@ -117,10 +121,12 @@ fn main() -> anyhow::Result<()> {
if let Ok(mut dao_lock) = dao.lock() {
let result = if existing.is_some() {
// Update existing record
dao_lock.update_exif(insert_exif).map(|_| "update")
dao_lock
.update_exif(&context, insert_exif)
.map(|_| "update")
} else {
// Insert new record
dao_lock.store_exif(insert_exif).map(|_| "insert")
dao_lock.store_exif(&context, insert_exif).map(|_| "insert")
};
match result {