Skip to content

fix: difference console counter rates per pod - #830

Merged
catinspace-au merged 1 commit into
mainfrom
fix/counter-rates-per-series
Oct 11, 2026
Merged

catinspace-au merged 1 commit into
mainfrom
fix/counter-rates-per-series

Conversation

@catinspace-au

Copy link
Copy Markdown
Contributor

The console summed each counter across the fleet per timestamp, then differenced the first and last totals. TimeUnix has one-second precision and pods export on their own clocks, so the totals rarely lined up and consecutive points subtracted one pod's counter from another's. Two pods each adding 100 over 60s, 7s apart, read 61.19/s instead of 3.33/s. The per-source signals had the same shape: two loader pods with flat counters read 3582 records a minute and a fresh arrival on every export.

Each series is now differenced against its own previous reading and the per-series rates are summed. A series is one metric name, one attribute set and one pod (service.instance.id), the key latest_gauges uses. A reading below the one before it is a restart and counts from zero, so a restart no longer reads as negative throughput (counter_rates) or as no reading at all (source signals).

source_landing_counter now returns one row per series - increase, span and the epoch second of its latest rise - and source_signals sums the rates and takes the latest rise across them.

New integration tests write to the real otel_metrics_sum table (tests/integration/test_counter_rates_ch.py). They run at the full tier, not in PR CI, so they were run locally against ClickHouse 26.3 with DFE_TEST_TIER=local. Old code against new:

  • two pods 7s apart: 61.19 vs 3.33/s
  • a mid-window restart: -15.67 vs 1.67/s
  • a pod appearing mid-window: 1.67 vs 3.67/s
  • two loader pods 7s apart: 3671.6 vs 200 records a minute
  • flat loader pods: 3582 a minute and an arrival vs 0 and none
  • a restarted loader pod: null vs 100 a minute
  • a single pod, and two attribute sets on one pod, read the same on both

Replicas that push without service.instance.id still share one series, and the alternation between their counters counts as traffic. The query comment says so.

The console summed each counter across the fleet per timestamp, then differenced the first and last totals. TimeUnix has one-second precision and pods export on their own clocks, so the totals rarely lined up and consecutive points subtracted one pod's counter from another's. Two pods each adding 100 over 60s, 7s apart, read 61.19/s instead of 3.33/s. The per-source signals had the same shape: two loader pods with flat counters read 3582 records a minute and a fresh arrival on every export.

Each series is now differenced against its own previous reading and the per-series rates are summed. A series is one metric name, one attribute set and one pod (service.instance.id), the key latest_gauges uses. A reading below the one before it is a restart and counts from zero, so a restart no longer reads as negative throughput (counter_rates) or as no reading at all (source signals).

source_landing_counter now returns one row per series - increase, span and the epoch second of its latest rise - and source_signals sums the rates and takes the latest rise across them.

New integration tests write to the real otel_metrics_sum table. Old code against new: two pods 7s apart 61.19 vs 3.33/s, a mid-window restart -15.67 vs 1.67/s, a pod appearing mid-window 1.67 vs 3.67/s, two loader pods 3671.6 vs 200 records a minute, flat loader pods 3582 vs 0 with no arrival, a restarted loader pod null vs 100 a minute. A single pod and two attribute sets on one pod read the same on both.
@catinspace-au
catinspace-au merged commit 022b364 into main Oct 11, 2026
20 checks passed
@catinspace-au
catinspace-au deleted the fix/counter-rates-per-series branch October 11, 2026 23:31
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant