diff options
Diffstat (limited to 'pingora-cache')
-rw-r--r-- | pingora-cache/src/lib.rs | 14 | ||||
-rw-r--r-- | pingora-cache/src/trace.rs | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/pingora-cache/src/lib.rs b/pingora-cache/src/lib.rs index f747672..bc370b7 100644 --- a/pingora-cache/src/lib.rs +++ b/pingora-cache/src/lib.rs @@ -457,9 +457,19 @@ impl HttpCache { } } + // Get the cache parent tracing span + pub fn get_cache_span(&self) -> Option<trace::SpanHandle> { + self.inner.as_ref().map(|i| i.traces.get_cache_span()) + } + // Get the cache `miss` tracing span - pub fn get_miss_span(&mut self) -> Option<trace::SpanHandle> { - self.inner.as_mut().map(|i| i.traces.get_miss_span()) + pub fn get_miss_span(&self) -> Option<trace::SpanHandle> { + self.inner.as_ref().map(|i| i.traces.get_miss_span()) + } + + // Get the cache `hit` tracing span + pub fn get_hit_span(&self) -> Option<trace::SpanHandle> { + self.inner.as_ref().map(|i| i.traces.get_hit_span()) } // shortcut to access inner, panic if phase is disabled diff --git a/pingora-cache/src/trace.rs b/pingora-cache/src/trace.rs index 58f3511..e48ae6f 100644 --- a/pingora-cache/src/trace.rs +++ b/pingora-cache/src/trace.rs @@ -46,6 +46,10 @@ impl CacheTraceCTX { self.cache_span = cache_span; } + pub fn get_cache_span(&self) -> SpanHandle { + self.cache_span.handle() + } + #[inline] pub fn child(&self, name: &'static str) -> Span { self.cache_span.child(name, |o| o.start()) @@ -70,6 +74,10 @@ impl CacheTraceCTX { .set_tag(|| Tag::new("status", hit_status.as_str())); } + pub fn get_hit_span(&self) -> SpanHandle { + self.hit_span.handle() + } + pub fn finish_hit_span(&mut self) { self.hit_span.set_finish_time(SystemTime::now); } |