Analytics for sub-requests

Summary

It seems that requests from one zone (site) to a sub-zone (site) don’t show up in the latter’s analytics.

Background

We have a main zone (mycompany.com) and a sub-zone (api.mycompany.com). The DNS configuration on the main zone points api.mycompany.com to the sub-zone via NS records. The DNS configuration for the sub-zone points api.mycompany.com to our origin via a CNAME.

The main zone receives traffic on www.mycompany.com and then uses a worker to (conditionally) change the request hostname to api.mycompany.com, then forward the request upstream via fetch.

Problem

When I look at the [analytics for the main zone, I see thousands of requests going upstream. I would expect a significant portion of those requests to go to the api sub-zone, yet when I look at the analytics for the api sub-zone, I see very few requests coming through – fewer than a dozen.

As far as the sub-zone is concerned, it’s receiving traffic, so I would expect that to show up in the Analytics and Cachine tabs in the UI.