Skip to content

Commit

Permalink
Add span to record memory cache read API call.
Browse files Browse the repository at this point in the history
  • Loading branch information
mar-cf committed Sep 18, 2024
1 parent 6f43bbc commit b0b93e3
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 b0b93e3

Please sign in to comment.