From 88a5a65c767cd99413de4424b62363590e1ffabc Mon Sep 17 00:00:00 2001 From: Mar Witek Date: Mon, 16 Sep 2024 15:57:55 -0500 Subject: [PATCH] Add span to record memory cache read API call. --- src/workerd/api/memory-cache.c++ | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workerd/api/memory-cache.c++ b/src/workerd/api/memory-cache.c++ index 7a6f165f098..21d2c8e392f 100644 --- a/src/workerd/api/memory-cache.c++ +++ b/src/workerd/api/memory-cache.c++ @@ -370,6 +370,8 @@ jsg::Promise> MemoryCache::read(jsg::Lock& js, return js.rejectedPromise>(js.rangeError("Key too large."_kj)); } + auto readSpan = IoContext::current().makeTraceSpan("memory_cache_read"_kjc); + KJ_IF_SOME(fallback, optionalFallback) { KJ_SWITCH_ONEOF(cacheUse.getWithFallback(key.value)) { KJ_CASE_ONEOF(result, kj::Own) { @@ -379,7 +381,7 @@ jsg::Promise> MemoryCache::read(jsg::Lock& js, } KJ_CASE_ONEOF(promise, kj::Promise) { return IoContext::current().awaitIo(js, kj::mv(promise), - [fallback = kj::mv(fallback), key = kj::str(key.value)]( + [fallback = kj::mv(fallback), key = kj::str(key.value), span = kj::mv(readSpan)]( jsg::Lock& js, SharedMemoryCache::Use::GetWithFallbackOutcome cacheResult) mutable -> jsg::Promise> { KJ_SWITCH_ONEOF(cacheResult) {