diff options
Diffstat (limited to 'pingora-cache/src/trace.rs')
-rw-r--r-- | pingora-cache/src/trace.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pingora-cache/src/trace.rs b/pingora-cache/src/trace.rs index c385aea..58f3511 100644 --- a/pingora-cache/src/trace.rs +++ b/pingora-cache/src/trace.rs @@ -74,14 +74,14 @@ impl CacheTraceCTX { self.hit_span.set_finish_time(SystemTime::now); } - pub fn log_meta(&mut self, meta: &CacheMeta) { + fn log_meta(span: &mut Span, meta: &CacheMeta) { fn ts2epoch(ts: SystemTime) -> f64 { ts.duration_since(SystemTime::UNIX_EPOCH) .unwrap_or_default() // should never overflow but be safe here .as_secs_f64() } let internal = &meta.0.internal; - self.hit_span.set_tags(|| { + span.set_tags(|| { [ Tag::new("created", ts2epoch(internal.created)), Tag::new("fresh_until", ts2epoch(internal.fresh_until)), @@ -95,4 +95,12 @@ impl CacheTraceCTX { ] }); } + + pub fn log_meta_in_hit_span(&mut self, meta: &CacheMeta) { + CacheTraceCTX::log_meta(&mut self.hit_span, meta); + } + + pub fn log_meta_in_miss_span(&mut self, meta: &CacheMeta) { + CacheTraceCTX::log_meta(&mut self.miss_span, meta); + } } |