Repository navigation
fix(blocks): métricas OTLP em delta e sem service.instance.id - #751
Merged
Merged
Conversation
O meter OTLP exportava cumulativo com buffer que nunca zerava: cada flush (~5s) reenviava toda série que o isolate já tinha visto, e o UUID por isolate no resource impedia somar isolates. Resultado: ~600M linhas/dia em otel_metrics_histogram. Refs #750
Contributor
Author
|
Verdict: LGTM — the snapshot/clear and the DELTA switch are correct, and I found nothing in this repo that breaks (round 1) BlockingNone. Worth fixing
Not verifiable from this repo
Checked, fine
|
…ários de temporalidade
Contributor
Author
|
Verdict: LGTM: the round-1 kind-mismatch gap is closed correctly and nothing in the fix commit regresses (round 2) Previously raised
BlockingNone. Worth fixing
Checked, fine
|
|
🎉 This PR is included in version 7.81.4 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #750
Problema
otel_metrics_histogramestá com ~462 GB no stats-lake: 24,9 bilhões de linhas em 90 dias, cerca de 600 milhões por dia. A causa está no meter OTLP do 7.x (sdk/otelHttpMeter.ts+sdk/otel.ts):Mapinteiro. Um isolate que já atendeu N combinações de rota×status×região grava N linhas a cada 5s até morrer, mesmo das séries que ficaram paradas.service.instance.id = crypto.randomUUID()no resource das métricas. Com cumulativo, o id é obrigatório para não misturar totais de isolates diferentes. Só que os isolates do Workers giram o tempo todo (5.273 ids distintos em 1h num único site), então cada isolate abre o seu próprio conjunto de séries e nada se agrega.Exemplo do efeito:
deco.loader.duration, com só 20 combinações de atributos, gera 30 milhões de linhas por dia num único tenant.Mudança
otelHttpMeter.ts: temporalidade DELTA (aggregationTemporality: 1), igual aov8/telemetry.tsdomain. O flush tira um snapshot do buffer e o zera de forma síncrona, antes do primeiroawait. Assim, o que for gravado durante o POST cai na janela seguinte. OstartTimeUnixNanode counters e histogramas passa a ser o início da janela (o último flush), e não mais o boot do isolate. Séries paradas deixam de ser reenviadas.otel.ts: o resource das métricas não leva maisservice.instance.id. Pontos delta de isolates diferentes devem ser somados, e o UUID os separaria de novo. Logs e traces continuam com o id.Trade-off: se o POST falhar, a janela dele se perde (≤
minFlushIntervalMs, 5s por padrão de um isolate) em vez de voltar para o buffer. No modo cumulativo, a perda se recuperava no flush seguinte. Deixei um comentárioponytail:no ponto; dá para adicionar um buffer de retry se a perda aparecer.Atenção na revisão: quem consome
Antes do merge, verificar consultas e dashboards no ClickHouse/Grafana que leem
otel_metrics_histogram/otel_metrics_sumassumindo cumulativo, por exemplo diferença entre linhas consecutivas oumax(Count)por série. Com delta, o certo ésum(Count)esumForEach(BucketCounts)na janela. Dados antigos (AggTemp = 2) e novos (AggTemp = 1) vão conviver até o TTL vencer; dá para filtrar porAggregationTemporality. Também confirmar que odeco-otel-ingest/collector não tem umcumulativetodeltaque esperava o id.Fora deste PR, ficam na #750:
http.routeainda vaza segmentos de uma palavra só;deco.http.region(166 valores) no histograma; mexer nisso esbarra no fan-out para o AE, que quer a região;_block_offsetmaterializada e o TTL de 90 dias (infra).Testes
otelHttpMeter.test.ts:1;countsó da janela estartTimeUnixNano= flush anterior; a série parada não é reenviada.bunx vitest run packages/blocks/src/sdk/: 501/501.tsc --noEmitempackages/blocks: limpo.biome checknos 3 arquivos: 3 erros de formatação que já existem no7.xsem este PR.ServiceName.Summary by cubic
Fixes the stats-lake bloat in
otel_metrics_histogram(~600M rows/day) by switching the OTLP meter from cumulative to delta aggregation and dropping the per-isolateservice.instance.idfrom metrics resources. Previously, each ~5s flush re-exported every series the isolate had ever seen, and since Workers isolates rotate constantly, every one opened its own series set and nothing aggregated.Bug Fixes
otelHttpMeter.tsnow exports withAggregationTemporality = DELTA; each flush snapshots the buffer and clears it synchronously, so idle series are not re-sent andstartTimeUnixNanobecomes the window start instead of isolate boot.service.instance.idwhile logs and traces keep it. A failed POST now loses at mostminFlushIntervalMs(5s) of data instead of recovering it on the next flush.Migration
otel_metrics_histogram/otel_metrics_sumas cumulative (max(Count), row-to-row differences) must switch tosum()over the window.AggregationTemporality = 2) and new delta rows (= 1) coexist until TTL expires; filter by that column if needed.Refs
decocms/blocks#750.Written for commit c7e26cc. Summary will update on new commits.