Repository navigation
Description
Measured (stats-lake ClickHouse, 2026-10-22)
default.otel_metrics_histogram is ~462 GB (~430 GiB compressed), the largest table in stats-lake: 24.9B rows for 90 days of TTL, so ~600M rows/day.
Top producers, last 24h (tenants anonymized):
| Tenant | MetricName | rows/day | distinct Attributes |
distinct ResourceAttributes |
|---|---|---|---|---|
| tenant-a | http.server.request.duration | 105M | 77k | 140k |
| tenant-b | http.server.request.duration | 81M | 25k | 73k |
| tenant-c | http.server.request.duration | 73M | 23k | 164k |
| tenant-d | http.server.request.duration | 33M | 16k | 65k |
| tenant-a | deco.loader.duration | 30M | 20 | 103k |
That last row matters: even a metric with only 20 attribute combinations produces 30M rows/day. Attributes are not where the rows come from. The resource is.
Key cardinality, last 1h:
- tenant-d
ResourceAttributes:service.instance.id= 5,273 distinct values. Every other key has 1 or 2. - tenant-a
Attributes:http.route= 5,300 (shape:/:slug/<category>/<subcategory>/<brand>/:slug/:slug/:slug/:id/<color>/<size>),deco.http.region= 166. Everything else is ≤ 21.
Bytes per column: TimeUnix+StartTimeUnix 125 GiB, ResourceAttributes 64 GiB, BucketCounts+ExplicitBounds 79 GiB, and _block_offset 64 GiB, a materialized virtual column that holds no data we use.
Cause (code at blocks-v7.79.8)
The rows are the product of three choices:
- A per-isolate resource id.
packages/blocks/src/sdk/otel.ts:799sets[ATTR_SERVICE_INSTANCE_ID]: crypto.randomUUID()in the resource floor for every metric. Workers churn isolates constantly, across every colo and on every deploy or memory eviction, so each isolate opens a fresh set of series and none of them aggregate across isolates. - Cumulative temporality and a buffer that is never reset.
packages/blocks/src/sdk/otelHttpMeter.ts:180documents the buffer as "per-isolate, never reset (CUMULATIVE temporality)".serializeOtlpserializes the wholeMapwithaggregationTemporality: 2on every flush. - A flush every ~5 s (
minFlushIntervalMs: 5000), triggered from each request'swaitUntil.
As a result, an isolate that has served N distinct route×status×region combinations writes N histogram rows every 5 s for its whole life, including series that have been idle since boot.
Separately, normalizePath (packages/blocks/src/middleware/observability.ts:727, the follow-up to #428) only collapses hyphenated, numeric and hex segments. Single-word path segments (category, brand, color and size words) survive literally, so http.route is still unbounded on the CMS catch-all.
Why simply dropping the id is not enough
With cumulative points, removing service.instance.id (in the SDK or in the collector) would make many isolates write running totals into the same series. Counts would look like constant resets and rates and percentiles would be wrong. The id is load-bearing because the temporality is cumulative.
main already moves in the right direction: packages/blocks/src/v8/telemetry.ts:295 uses aggregationTemporality: 1 // DELTA.
Proposal
- Delta temporality for the 7.x OTLP meter, the same as v8: reset the buffer after each successful flush and send only the points that changed. This alone removes the re-export of idle series.
- With delta in place, drop
service.instance.idfrom the metrics resource. Keep it on traces and logs, where per-instance attribution (memory creep, cold starts) is actually used. - Bound
http.route: use the matched route template or page type (pdp/plp/home/search/cms) instead of a regex over the raw path. - Take
deco.http.regionoff the histogram (166 values). Keep it on spans, or AE, which is already the "high-cardinality drill-down" backend. - Infra, outside this repo: disable the materialized
_block_offsetcolumn onotel_metrics_*, and reconsider the 90-day TTL for histograms.
Repro query
SELECT k, uniqExact(v) AS vals, any(v) AS ex
FROM default.otel_metrics_histogram
ARRAY JOIN mapKeys(ResourceAttributes) AS k, mapValues(ResourceAttributes) AS v
WHERE ServiceName = '<site>'
AND MetricName = 'http.server.request.duration'
AND TimeUnix > now() - INTERVAL 1 HOUR
GROUP BY k ORDER BY vals DESC;Swap ResourceAttributes for Attributes to get the route breakdown.
Activity
fix(blocks): métricas OTLP em delta e sem service.instance.id (#751)