Skip to content

chore: retire the aether_stats stats_tags regex workaround (#695 step 4) - #707

Merged
bpalermo merged 2 commits into
mainfrom
chore/695-retire-stats-tags-regexes
Sep 5, 2026
Merged

bpalermo merged 2 commits into
mainfrom
chore/695-retire-stats-tags-regexes

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

Why the regexes existed

aether_stats (proposal 012) records one counter per request via
counterFromStatNameWithTags, which inlines the tag values into the full
stat name (aether.requests_total.reporter.<v>.source_service.<v>.…). On the
filter's write path those are real Stats tags — but the node proxy hot-restarts
on every config change (talos-main reached epoch 53), and Envoy's StatMerger
re-created every merged counter via counterFromStatName() with no tags
("TODO(snowp): Propagate tag values during hot restarts"). After the first
restart the programmatic tags were gone and their values collapsed into the
metric name with empty labels — the talos-main symptom: series named
…aether.requests_total.reporter.source.… instead of one metric with labels.

The workaround was seven stats_tags regexes in the proxy bootstrap, one per
programmatic key, re-deriving the tags from the mangled name.

Why they can go now

The proxy is built from the Envoy main snapshot pinned in #697, which contains
envoyproxy/envoy#45674 "hot restart: propagate programmatic stat tags across
restart"
. The parent now transmits each tagged stat's metadata
(hot_restart.proto TaggedMetric / counter_tags) and the child re-creates
the counter through counterFromMergedStatName, so the tags survive natively.
Its runtime guard envoy.reloadable_features.hot_restart_propagate_stat_tags is
a default-true RUNTIME_GUARD at the pinned commit (13144fb).

What changed

  • charts/aether/templates/agent-proxy-configmap.yaml: the seven programmatic
    regexes (reporter, source_service, source_pod, destination_service,
    destination_pod, response_code, response_flags) are gone, replaced by a
    short note pointing at envoy#45674 and the guarding test. aether.cluster
    and aether.pod stay
    — those extract from Envoy's own cluster.* /
    listener.* stat names and were never part of the workaround.
    helm template charts/aether now renders exactly two tag_name entries.
  • charts/aether/Chart.yaml: 0.92.2 → 0.92.3.
  • proxy/.../aether_stats/tag_extraction_test.cc: rewritten around the new
    invariant instead of the regex list.

What the new test guards

With no aether_stats stats_tags regexes configured anywhere:

  1. FreshCounterIsTagged — the filter's own counter is clean: tag-extracted name
    aether.requests_total plus seven label tags; the values are only inlined in
    the flat name.
  2. TagsSurviveHotRestartWithoutRegexes — a real FilterConfig::record() into a
    "parent" ThreadLocalStoreImpl, then a StatMerger merge into a "child"
    store built exactly as HotRestartingChild::mergeParentStats builds it
    (counter delta + StatMerger::TagsMap ParentTags{base_name_, tags_},
    gated on the runtime guard). The merged counter has the same
    tagExtractedName and the same tag set as the fresh one, and the child's
    own post-restart write resolves to that same counter (value 2, no poisoned
    central-cache slot / mangled twin). It also asserts the guard is on by
    default, so a future re-pin that flipped it fails here rather than on talos.
  3. TagsLostWhenPropagationDisabled — the negative case that makes the above
    meaningful: with the guard forced off, no metadata is sent, the merged counter
    has zero tags and tagExtractedName is the full mangled name containing
    .reporter..
  4. RetainedChartRegexesStillExtract — the two kept chart regexes still lift
    aether.cluster / aether.pod out of Envoy's stat names, and extraction
    alone no longer recovers any programmatic key (propagation, not regex, is what
    recovers them).

One thing the first CI run surfaced and the test now pins: the filter interns tag
values through a StatNameDynamicPool, so the counter's StatName mixes
symbolic and dynamic segments. The merge therefore has to carry the parent's
dynamic spans (SymbolTable::getDynamicSpans, which
HotRestartingParent::exportStatsToChild transmits) alongside the tag metadata —
without them the child rebuilds an all-symbolic name and ends up with two
counters. Tags alone are not sufficient for the post-restart write to land on the
merged counter, and the test now proves both halves.

Upstream templates: ProgrammaticTagsSurviveMerge /
ProgrammaticTagsLostWithoutMetadata in test/common/stats/stat_merger_test.cc.

talos validation recipe (for the main session)

# deploy 0.92.3, then force a hot restart on every node with NO regexes present
kubectl -n aether-system rollout restart ds/aether-proxy
kubectl -n aether-system rollout status ds/aether-proxy

After the roll, in Grafana / Prometheus:

# every series must still carry the programmatic labels
count(aether_requests_total{reporter!="",source_service!=""}) == count(aether_requests_total)

and assert the historical collapse symptom is absent — no series whose name
contains .reporter. (e.g. count({__name__=~".*\\.reporter\\..*"}) is empty).

Refs #695 — deliberately not closing it: the re-pin to a 1.40.0.envoy module
and the root @envoy_binary_linux_* bump remain.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 2 commits September 5, 2026 16:26
…tart (envoy#45674)

The aether_stats filter records via counterFromStatNameWithTags, which inlines
the tag VALUES into the full stat name. Envoy's StatMerger used to re-create a
merged counter with counterFromStatName() and NO tags, so after the node proxy's
first hot restart the programmatic tags were gone and collapsed into the metric
name (talos-main epoch 53). The chart papered over that with one stats_tags
regex per programmatic key; tag_extraction_test asserted those regexes
re-derived the seven keys from the merged name.

envoyproxy/envoy#45674 — in the pinned proxy snapshot, runtime guard
envoy.reloadable_features.hot_restart_propagate_stat_tags default on — makes the
parent transmit the tag metadata (hot_restart.proto TaggedMetric / counter_tags)
and the child re-create the counter via counterFromMergedStatName, so the tags
survive natively.

Rewrite the test around that invariant, with no aether_stats stats_tags regexes
configured anywhere:

- FreshCounterIsTagged: the filter's own counter is clean (bare
  aether.requests_total + seven label tags).
- TagsSurviveHotRestartWithoutRegexes: a real FilterConfig::record() in a
  "parent" ThreadLocalStore, merged into a "child" store through StatMerger with
  the parent tag metadata exactly as HotRestartingChild::mergeParentStats builds
  it (including the runtime gate), yields a counter indistinguishable from the
  fresh one — same tagExtractedName, same tags — and the child's own post-restart
  write lands on that same counter rather than a mangled twin. Also asserts the
  runtime guard is on by default, so a re-pin that flipped it fails here.
- TagsLostWhenPropagationDisabled: with the guard forced off no metadata is sent,
  the merged counter has zero tags and the values stay welded into the name —
  the pre-fix symptom, kept so the invariant means something.
- RetainedChartRegexesStillExtract: the two regexes the chart keeps
  (aether.cluster, aether.pod) still extract from Envoy's own stat names, and no
  regex re-derives the programmatic keys any more.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
)

The proxy is built from an Envoy snapshot that contains envoyproxy/envoy#45674
"hot restart: propagate programmatic stat tags across restart", whose runtime
guard envoy.reloadable_features.hot_restart_propagate_stat_tags is default on.
The hot restart parent now transmits each tagged stat's metadata and the child
re-creates the counter with its tags, so aether_stats' seven programmatic tags
(reporter, source_service, source_pod, destination_service, destination_pod,
response_code, response_flags) survive a restart natively.

Drop the seven stats_tags regexes that re-derived them from the flat stat name.
aether.cluster and aether.pod stay: those are genuine regex-extracted tags from
Envoy's own cluster.*/listener.* stat names, not part of the workaround.

//source/extensions/filters/http/aether_stats:tag_extraction_test in the proxy
workspace now guards the no-regex invariant.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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