8000 Fix #2093: add _total suffix to CHI/host/pod counter metrics by mehrdadbn9 · Pull Request #2097 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

Skip to content

Fix #2093: add _total suffix to CHI/host/pod counter metrics - #2097

Closed
mehrdadbn9 wants to merge 3 commits into
Altinity:0.28.0from
mehrdadbn9:contrib-2093-counter-total-suffix
Closed

mehrdadbn9 wants to merge 3 commits into
Altinity:0.28.0from
mehrdadbn9:contrib-2093-counter-total-suffix

Conversation

@mehrdadbn9
Copy link
Copy Markdown

Fixes #2093.

promtool check metrics flags our counters: the exporter is built with
prometheus.WithoutCounterSuffixes(), so OTel emits names verbatim and all 12
Int64Counter instruments in chi/metrics shipped without _total. This
renames them to *_total, including pod_update/pod_delete_events which were
absent from the original endpoint scrape and thus escaped #2093 but carry the
same latent defect. Histograms and the clickhouse_operator_chi UpDownCounter
intentionally unchanged.

Adds TestAllCountersCarryTotalSuffix and TestNonCounterShapesHaveNoTotalSuffix
as a regression guard using the OTel ManualReader. go vet and go test pass;
full pkg/controller/... builds clean.

Heads-up: metric rename is user-visible. Dashboards and recording rules
referencing the old names, for example
clickhouse_operator_chi_reconciles_started, need a one-line update to the
_total twin.

promtool check metrics flags any counter exposed without the conventional _total suffix. The operator ships its OTel Prometheus exporter with WithoutCounterSuffixes(), so names are emitted verbatim and the 12 Int64Counter instruments in chi/metrics carried non-compliant names. This renames all of them (including pod_update/pod_delete, which were absent from the original scrape and thus escaped Altinity#2093 but fail the same lint once emitted). Histograms and the UpDownCounter are intentionally untouched. Adds a regression test asserting monotonic counters carry _total and non-counters do not.

Signed-off-by: Mehrdad Biukian Naeini <mehrdadbiukian@gmail.com>
@mehrdadbn9
mehrdadbn9 marked this pull request as ready for review October 9, 2026 04:40
@mehrdadbn9 mehrdadbn9 changed the title Fix-2093-add-total-suffix Fix #2093: add _total suffix to CHI/host/pod counter metrics Oct 9, 2026
@alex-zaitsev
Copy link
Copy Markdown
Member

This will break existing dashboards.

@Slach Slach linked an issue Nov 3, 2026 that may be closed by this pull request
@Slach
Slach changed the base branch from 0.27.4 to 0.28.0 November 3, 2026 05:00
@Slach Slach self-assigned this Nov 6, 2026
@Slach
Slach commented Nov 6, 2026
Copy link
Copy Markdown
Collaborator

Thanks for the detailed PR, but we won't merge it.

Renaming 12 counters is a breaking change for users: existing Grafana dashboards, recording rules and alerts that use the current names will silently show no data after upgrade. As @alex-zaitsev already mentioned, _total compliance for promtool isn't worth that. Our own e2e tests (tests/e2e/test_operator.py) use these names too.

The exporter uses prometheus.WithoutCounterSuffixes() on purpose (pkg/metrics/operator/machinery.go) to keep the names stable. If we ever rename the metrics, it should be opt-in or a deprecation with both names exported for a few releases, not a hard rename.

Closing for now, #2093 stays open for discussion.

@Slach Slach closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Counter metrics are missing the conventional _total suffix

3 participants

0