This means that the request doesn’t reach your worker and is handled before that by some rule or other worker that redirects to 404 page. You need to check your other settings on CF and make an exception in them for your same origin path.
On Shopify same origin is not possible. To make it work you need to proxy all site traffic through CF, and Shopify doesn’t have that option. So your request for /metrics just doesn’t get to Cloudflare, it’s processed by Shopify and sent to a 404 page as no such page exists.