Skip to content

Onset parent for RPC-based tracers, user span for cache subrequests - #7406

Draft
mar-cf wants to merge 2 commits into
mainfrom
mar/user-tracing
Draft

mar-cf wants to merge 2 commits into
mainfrom
mar/user-tracing

Conversation

@mar-cf

@mar-cf mar-cf commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

No description provided.

An RPC-based tracer reports the onset from a deserialized context,
which has no parent, so the onset was never linked to its caller.
CacheClient::SubrequestMetadata carried only the internal span, so
embedders could not attach cache subrequests to the user trace.
@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

The in-tree CacheClientImpl drops the new userSpanParent before it starts the cache-service subrequest. As a result, cache.match(), put(), and delete() still begin the downstream request without a user trace trigger, despite Cache::getHttpClient() supplying one. Forward it alongside the internal parent.

    kj::Own<kj::HttpClient> getDefault(CacheClient::SubrequestMetadata metadata) override {
      return kj::heap<CacheHttpClientImpl>(*cacheService, cacheNamespaceHeader, kj::none,
          kj::mv(metadata.cfBlobJson), kj::mv(metadata.parentSpan),
          kj::mv(metadata.userSpanParent));
    }

    kj::Own<kj::HttpClient> getNamespace(
        kj::StringPtr cacheName, CacheClient::SubrequestMetadata metadata) override {
      auto encodedName = kj::encodeUriComponent(cacheName);
      return kj::heap<CacheHttpClientImpl>(*cacheService, cacheNamespaceHeader, kj::mv(encodedName),
          kj::mv(metadata.cfBlobJson), kj::mv(metadata.parentSpan),
          kj::mv(metadata.userSpanParent));
    }

   private:
    kj::Own<IoChannelFactory::SubrequestChannel> cacheService;
    kj::HttpHeaderId cacheNamespaceHeader;
  };

  class CacheHttpClientImpl final: public kj::HttpClient {
   public:
    CacheHttpClientImpl(IoChannelFactory::SubrequestChannel& parent,
        kj::HttpHeaderId cacheNamespaceHeader,
        kj::Maybe<kj::String> cacheName,
        kj::Maybe<kj::String> cfBlobJson,
        SpanParent parentSpan,
        SpanParent userSpanParent)
        : client(asHttpClient(parent.startRequest({.cfBlobJson = kj::mv(cfBlobJson),
              .parentSpan = kj::mv(parentSpan),
              .userSpanParent = kj::mv(userSpanParent)}))),

@ask-bonk

ask-bonk Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

I'm Bonk, and I've done a quick review of your PR.

Updates tracer onset parenting and cache subrequest user-span propagation.

  1. [P1] src/workerd/server/server.c++:4282 drops userSpanParent, so cache subrequests remain detached from user traces. Suggestion posted.

Time for a pun! This cache trace has a parent problem: it was never properly forwarded.

github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant