Commit 67ea0b3
fix(loader): label loader_cache with the block key, not the resolve chain
`loader_cache` and `resolver_latency` were labelled with `ctx.resolverId`, which
carries the full resolve chain:
Categories@sections.variants.1.value.5.sections.0.section.page
SearchResults Global@sections.0.section.page
Categories@sections.variants.1.value.2.jsonLD
Every section position, of every variant, of every page becomes its own time
series. That is an identifier, not a dimension.
Measured on the production ClickHouse:
distinct `loader` values, 3h window
fila-store 3,684
todolivrooficial 3,478
montecarlo 2,209
farmrio 1,469
happybooksoficial 1,028
fleet total 21,849
Against the budget documented in our own o11y guide — >1,000 per site is
forbidden as an alert dimension and >100 fleet-wide as a cross-fleet
aggregation — five sites are over and the fleet figure is 218x over. The cost
is real: `loader_cache` is 11,485,954 of 14,998,196 rows in otel_metrics_sum
over 3h, i.e. 76.6% of the whole table, and that table holds 48.4 GB.
For contrast, `cache_hit` covers 194 tenants in 9 series, and the
@decocms/start runtime does the equivalent job with 13 distinct
`deco.cache.profile` values fleet-wide.
The fix uses the block key that `adapt` already receives — the loader's module
path, e.g. `vtex/loaders/legacy/productListingPage.ts` — which is bounded by
the number of loader modules in the app. It is threaded into `wrapLoader` as a
new parameter; `wrapLoader` is module-private with a single call site.
What is lost: the metric can no longer distinguish two instances of the same
loader sitting in different sections. That trade is deliberate. The chain is
still carried on error logs, where high cardinality is acceptable because they
are read by point lookup rather than aggregated — and the o11y guide draws
exactly that line: high-cardinality attributes are fine for filtering and point
lookups, forbidden as aggregation keys.
`ctx.resolverId` is kept as a fallback so behaviour is unchanged if a caller
ever passes an empty key.
Verified: deno check blocks/loader.ts clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 40762b5 commit 67ea0b3
1 file changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
191 | 198 | | |
192 | 199 | | |
193 | 200 | | |
| |||
208 | 215 | | |
209 | 216 | | |
210 | 217 | | |
211 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
212 | 233 | | |
213 | 234 | | |
214 | 235 | | |
| |||
365 | 386 | | |
366 | 387 | | |
367 | 388 | | |
368 | | - | |
| 389 | + | |
369 | 390 | | |
370 | 391 | | |
371 | 392 | | |
| |||
0 commit comments