My personal site cherry.computer
htmx tailwind axum askama

feat: add tracing instrumentation for media fetch functions

cherry.computer 50e36a46 33078661

verified
+9
+3
server/src/scrapers/apple_music.rs
··· 5 5 use reqwest::Client; 6 6 use serde::{Deserialize, Serialize}; 7 7 use tokio::sync::RwLock; 8 + use tracing::instrument; 8 9 9 10 use super::{ 10 11 Media, ··· 121 122 }) 122 123 } 123 124 125 + #[instrument(name = "apple_music_try_cached_fetch", skip(self))] 124 126 pub fn try_cached_fetch(self: Arc<Self>) -> Option<Media> { 125 127 try_cache_or_fetch(&self.cache.clone(), TTL, async move || self.fetch().await) 126 128 } 127 129 130 + #[instrument(name = "apple_music_cached_fetch", skip(self))] 128 131 pub async fn cached_fetch(self: Arc<Self>) -> Option<Media> { 129 132 cache_or_fetch(&self.cache.clone(), TTL, async move || self.fetch().await).await 130 133 }
+3
server/src/scrapers/backloggd.rs
··· 7 7 use reqwest::Url; 8 8 use scraper::{Html, Selector}; 9 9 use tokio::sync::RwLock; 10 + use tracing::instrument; 10 11 11 12 use super::{ 12 13 Media, ··· 80 81 81 82 static CACHE: LazyLock<MediaCache> = LazyLock::new(|| Arc::new(RwLock::new(None))); 82 83 static TTL: Duration = Duration::from_secs(300); 84 + #[instrument(name = "backlogged_try_cached_fetch")] 83 85 pub fn try_cached_fetch() -> Option<Media> { 84 86 try_cache_or_fetch(&CACHE, TTL, fetch) 85 87 } 88 + #[instrument(name = "backlogged_cached_fetch")] 86 89 pub async fn cached_fetch() -> Option<Media> { 87 90 cache_or_fetch(&CACHE, TTL, fetch).await 88 91 }
+3
server/src/scrapers/letterboxd.rs
··· 8 8 use scraper::{ElementRef, Html, Selector}; 9 9 use serde::Deserialize; 10 10 use tokio::sync::RwLock; 11 + use tracing::instrument; 11 12 12 13 use super::{ 13 14 Media, ··· 143 144 144 145 static CACHE: LazyLock<MediaCache> = LazyLock::new(|| Arc::new(RwLock::new(None))); 145 146 static TTL: Duration = Duration::from_secs(1800); 147 + #[instrument(name = "letterboxd_try_cached_fetch")] 146 148 pub fn try_cached_fetch() -> Option<Media> { 147 149 try_cache_or_fetch(&CACHE, TTL, fetch) 148 150 } 151 + #[instrument(name = "letterboxd_cached_fetch")] 149 152 pub async fn cached_fetch() -> Option<Media> { 150 153 cache_or_fetch(&CACHE, TTL, fetch).await 151 154 }