Skip to content

Log cache status and deliveryZonesHash presence for intsch calls#561

Open
LucasTornai wants to merge 2 commits into
mainfrom
claude/cache-hit-logs-search-6c827e
Open

Log cache status and deliveryZonesHash presence for intsch calls#561
LucasTornai wants to merge 2 commits into
mainfrom
claude/cache-hit-logs-search-6c827e

Conversation

@LucasTornai

@LucasTornai LucasTornai commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Log whether product-search and facets calls to intsch (the live Intelligent Search client) were served from the router cache, plus whether the request's segment carried a deliveryZonesHash.
  • No metrics facility was granular enough for this, so this adds a structured log line instead, read from the x-router-cache response header (HeaderKeys.ROUTER_CACHE) — the same signal @vtex/api uses internally to tag tracing spans.

Details

  • node/clients/intsch/index.ts: facets() and productSearch() now use getRaw instead of get to access response headers, and log { message: 'IntelligentSearch cache status', route, cacheHit, hasDeliveryZonesHash } via ctx.vtex.logger.info. deliveryZonesHash presence is read from segmentParams, which is how it already flows into both methods.

Test plan

  • yarn lint (tsc --noEmit) passes
  • yarn test — 179 passed / 3 skipped, no regressions

Edit: this PR previously targeted the deprecated intelligent-search-api.ts (Biggy) client — restarted from latest main and moved the logging to intsch per review feedback below.

@LucasTornai LucasTornai requested a review from a team as a code owner July 10, 2026 17:20
@vtex-io-ci-cd

vtex-io-ci-cd Bot commented Jul 10, 2026

Copy link
Copy Markdown

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@vtex-io-docs-bot

Copy link
Copy Markdown

Beep boop 🤖

I noticed you didn't make any changes at the docs/ folder

  • There's nothing new to document 🤔
  • I'll do it later 😞

In order to keep track, I'll create an issue if you decide now is not a good time

  • I just updated 🎉🎉

Comment thread node/clients/intelligent-search-api.ts Outdated
path: string,
options?: FacetsOptions
) {
public async facets(params: FacetsArgs, path: string, shippingHeader?: string[], hasDeliveryZonesHash?: boolean) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you meant to target the intsch client, this one is supposed to be dead already

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — you're right, this was targeting the deprecated Biggy client. The branch also turned out to be based on a very stale snapshot of main (~117 commits behind), so I restarted the work from current main and moved the cache-status logging to intsch (node/clients/intsch/index.ts) instead, using segmentParams.deliveryZonesHash for the delivery-zones signal since that's how it already flows into facets/productSearch there.

Restarted this off latest main: the previous commit targeted
intelligent-search-api.ts, which is the deprecated Biggy client
and no longer where product-search/facets traffic actually goes
(per PR #561 review). intsch is now the live client, so log
router-cache status (HeaderKeys.ROUTER_CACHE) and whether the
request's segment carried a deliveryZonesHash there instead.
@LucasTornai LucasTornai force-pushed the claude/cache-hit-logs-search-6c827e branch from 1d0d012 to d1b7b07 Compare July 10, 2026 17:45
@LucasTornai LucasTornai requested a review from salesfelipe July 10, 2026 17:45
@LucasTornai LucasTornai changed the title Log cache status and deliveryZonesHash presence for intelligent-search calls Log cache status and deliveryZonesHash presence for intsch calls Jul 10, 2026
@salesfelipe salesfelipe added the enhancement New feature or request label Jul 10, 2026
Avoid logging every product-search/facets call at full volume;
10% sampling matches the existing Math.random() < 0.1 pattern
already used for the migration log in services/productSearch.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants