Skip to content

Commit

Permalink
Merge pull request #2717 from cloudflare/mar/memory-cache-span
Browse files Browse the repository at this point in the history
Add span to record memory cache read API call.
  • Loading branch information
mar-cf authored Sep 19, 2024
2 parents 5820b3b + 88a5a65 commit 3bb0d26
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/workerd/api/memory-cache.c++
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ jsg::Promise<jsg::JsRef<jsg::JsValue>> MemoryCache::read(jsg::Lock& js,
return js.rejectedPromise<jsg::JsRef<jsg::JsValue>>(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<CacheValue>) {
Expand All @@ -379,7 +381,7 @@ jsg::Promise<jsg::JsRef<jsg::JsValue>> MemoryCache::read(jsg::Lock& js,
}
KJ_CASE_ONEOF(promise, kj::Promise<SharedMemoryCache::Use::GetWithFallbackOutcome>) {
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<jsg::JsRef<jsg::JsValue>> {
KJ_SWITCH_ONEOF(cacheResult) {
Expand Down

0 comments on commit 3bb0d26

Please sign in to comment.