diff options
author | Matthew Gumport <[email protected]> | 2024-11-19 14:03:04 -0800 |
---|---|---|
committer | Yuchen Wu <[email protected]> | 2024-12-13 17:27:40 -0800 |
commit | 36d68e813506e12470b8c7cd5a088668e9912a12 (patch) | |
tree | 9cc2c73c3488d0198f5cae3524ca15f445f4c9a5 | |
parent | fa4654a04f870e1091f07068610755827ba1c425 (diff) | |
download | pingora-36d68e813506e12470b8c7cd5a088668e9912a12.tar.gz pingora-36d68e813506e12470b8c7cd5a088668e9912a12.zip |
expose getters for cache and hit spans
-rw-r--r-- | .bleep | 2 | ||||
-rw-r--r-- | pingora-cache/src/lib.rs | 14 | ||||
-rw-r--r-- | pingora-cache/src/trace.rs | 8 |
3 files changed, 21 insertions, 3 deletions
@@ -1 +1 @@ -624b1bc2959636de01cbb6f9da86df12784fa812
\ No newline at end of file +fc39bb0c3d35fa5e07c21c261c2a5a68af53d440
\ No newline at end of file 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); } |