Repository navigation
fix(agent): seed the UDPRoute-discard counter so it has a series (#882) - #905
Merged
Merged
Conversation
`aether.agent.l4route.udp_unsupported` — the counter #874 added to stop #873's silent discard — was registered but never seeded at zero. The OTel SDK exports a counter only after its first Add, so the series did not exist in Prometheus at all: a dashboard or alert built on it reads "no data" forever, which is indistinguishable from a healthy zero. Only the log half of #874 ever worked. Confirmed on talos-main (helm rev231): all four seeded siblings are present and no `aether_agent_l4route_*` metric is returned at all. The seed block's own comment said "the healthy case for all four" — it was written for four counters and the fifth was added to registration without being added to the list. That is the second time (the comment records the first, #638 on rev200), so the fix is not just the missing line: - seed `udpRouteUnsupported` at zero alongside the other four anomaly counters, and rewrite the comment for five; - `TestEveryRegisteredCounterDeclaresItsSeedPolicy` parses this package's own source (go:embed + go/ast) for every `meter.Int64Counter` registration and requires each one to be either exported-at-zero before any increment or listed as deliberately-not-seeded with a written reason. A counter added to `New()` with neither now fails here instead of in production. Also in the same registration: it returned a bare `err` where every sibling wraps, so a failure to register this one counter produced an unattributed error. And the doc comment for `StaleNetnsSkipped` had been orphaned above `UDPRouteUnsupported`, so godoc attached both to the wrong function. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 23, 2026
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.
Fixes #882.
The problem
aether.agent.l4route.udp_unsupported— the counter #874 added so #873's UDPRoute discards would stop being silent — is registered and then never seeded. The OTel SDK exports a counter only after its firstAdd, so until the first real discard the counter has no Prometheus series at all. A grading query reads "no data", which is indistinguishable from "healthy zero", "renamed", or "code path dead". Only the WARN-log half of #874 ever worked.Confirmed on the currently-deployed build (talos-main, helm rev231), listing every
aether_agent_(l4route|identity|snapshot)_*metric name:No
l4routemetric is returned at all. Same class as #853 (a shellcheck gate that linted zero files) and #880: a control that is configured, looks correct, and cannot report.What this changes
1. The seed.
m.udpRouteUnsupported.Add(ctx, 0)joins the four anomaly counters already seeded, and the block comment — which still said "the healthy case for all four" — is rewritten for five. That comment is the evidence this is a repeat: it was written for four counters after #638's two were found missing on rev200, and the fifth was added to registration without being added to the list.2. A gate that catches the next one. Per #882's acceptance criterion, the test asserts against the exported metric set rather than against the field list, and derives the expectation from the code instead of from a second hand-maintained list:
TestEveryRegisteredCounterDeclaresItsSeedPolicyembedscachemetrics.go(go:embed) and walks it withgo/astfor everymeter.Int64Counter("…")registration. It then collects a freshMetricsthrough aManualReaderwith nothing incremented, and requires every registered counter to be either:seededCounters, asserted separately at value 0), orcountersDeliberatelyNotSeededwith a written reason.A counter added to
New()with neither fails here. A stale entry in either list fails too, so the two cannot silently cancel out.3. Two things found in the same registration. It returned a bare
errwhere every sibling wraps (fmt.Errorf("stale netns skipped: %w", err)), so failing to register this one counter produced an unattributed error. And the doc comment forStaleNetnsSkippedhad been orphaned aboveUDPRouteUnsupported, so godoc attached the stale-netns text to the UDP function and leftStaleNetnsSkippedundocumented.Labels: there are none
The counter takes no attributes —
Add(ctx, n)with nometric.WithAttributes, deliberately, because the things it would carry (pod, service, cluster name) are unbounded cardinality and are logged at WARN instead. So there is exactly one series and it is fully seeded; nothing is left unseeded for lack of enumerability.The counters deliberately left unseeded
Five of the ten registered counters are not seeded, each with the reason recorded in the test:
aether.agent.snapshot.buildsaether.agent.snapshot.errorsTestCacheMetrics_GeneratedFailureasserts its absence alongside a buildaether.agent.upstreams.missaether.agent.upstreams.ttl_refreshedaether.agent.upstreams.restoredTestCacheMetrics_UpstreamsRestoredasserts that absencesnapshot.errorsis arguably a seed candidate on the same reasoning as the anomaly counters, but seeding it changes behaviour an existing test asserts, so it is out of scope for #882 rather than quietly bundled in.How the seeding was verified to produce a series
Seeding means recording a zero-valued observation, not merely declaring the instrument — so the assertion is made against the SDK's exported metric set (
ManualReader.Collect, the same aggregation the OTLP exporter reads), not against the instrument's existence.metricValuereturnsfound = falseprecisely when the metric has no data points, which is the bug's shape.The OTLP→Prometheus rename (
aether.agent.l4route.udp_unsupported→aether_agent_l4route_udp_unsupported_total) is out of the agent's hands, but the mechanism is already proven end-to-end by the four seeded siblings above: they are seeded the identical way and all four report a live series on rev231, while the one unseeded counter reports nothing. That is exactly the difference this PR removes.Negative controls — seen red, seen green
1. Remove the seeding
Deleting
m.udpRouteUnsupported.Add(ctx, 0)leaves the field still used byUDPRouteUnsupported(), so the package still compiles and the test is what fails — not the build:2. The actual recurring defect: a new counter registered without a seed decision
This is the case that matters, since #882 is the second occurrence. Registering
aether.agent.snapshot.next_counterinNew()and touching it nowhere else (_ = m.nextCounter, so it still compiles):Restored, green
The green run is itself the anti-vacuity proof for the new gate: its last assertion requires the source parse to have found exactly 10
Int64Counterregistrations, so a parse that matched nothing — or that stopped matching because the registration shape changed — fails rather than passing empty. That is the #853 failure mode, checked directly.Checks
bazel test //agent/internal/xds/cache/... //agent/internal/l4route/... //agent/internal/xds/proxy/...— 5/5 pass.bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //agent/internal/xds/cache/...— clean.make gazellerun; it picked up thego:embedand addedembedsrcs = ["cachemetrics.go"]to thego_test. No module change, so nomake tidy.charts/change, so noChart.yamlbump.🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr