Skip to content

fix(prober): give the seconds-valued duration histograms explicit seconds buckets (#732) - #733

Merged
bpalermo merged 1 commit into
mainfrom
fix/732-histogram-buckets
Sep 6, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/732-histogram-buckets

Conversation

@bpalermo

@bpalermo bpalermo commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Fixes #732.

The bug

prober/internal/prober records time.Since(start).Seconds() into
aether_probe_request_duration_seconds but created the instrument with no boundaries, so
it inherited the OTel SDK's defaults — 0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000 — which are tuned for values expressed in milliseconds.
Against a seconds-valued duration the first bucket is le="5" seconds: a healthy 2 ms
probe and a timed-out 2 s probe are indistinguishable. Control-tested on talos during the
#728 validation: all 18,394 pre-fix ~2 s timeout observations on one prober sit in
le=5, identical to +Inf.

Mechanism used: the instrument option, not a View

metric.WithExplicitBucketBoundaries has been an instrument option since otel metric
v1.20 and the repo pins go.opentelemetry.io/otel/metric v1.44.0 /
go.opentelemetry.io/otel/sdk/metric v1.44.0, so the option is honoured directly by the
SDK — no sdkmetric.NewView is needed (and none exists anywhere in the repo today; the
mesh-DNS resolver already uses the instrument option the same way). The new test asserts
against the exported data point through an sdkmetric.ManualReader, so it proves the
option actually reaches the SDK rather than just checking a package variable.

Boundaries chosen so the four regimes that matter are each separated:

0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 2.5, 5

healthy sub-10 ms probes · the 1 s resolver retransmit (#728) · the 2 s probe budget
(Config.Timeout) · the 5 s legacy resolver retransmit. Metric name and unit ("s")
are unchanged.

Sweep: every histogram instrument in the repo

grep -rn 'Float64Histogram\|Int64Histogram' --include='*.go' agent/ common/ registrar/ controller/ prober/ registry/ cni/

Instrument File Recorded value Boundaries before Status
aether_probe_request_duration_seconds prober/internal/prober/prober.go seconds (time.Since().Seconds()) SDK default (ms-oriented) FIXED — 0.001 … 1, 1.5, 2, 2.5, 5
aether.agent.snapshot.duration (unit s) agent/internal/xds/cache/cachemetrics/cachemetrics.go seconds SDK default (ms-oriented) FIXED — 0.0001 … 1, 2.5, 5 (a build is sub-ms to tens of ms)
aether.agent.liveness.promotion_delay_seconds agent/internal/cni/server/metrics.go seconds SDK default (ms-oriented) FIXED — 0.5 … 60, 90, 120, 300 (loop ticks every 5 s)
aether.registrar.sync.duration (unit s) registrar/internal/server/metrics.go seconds SDK default (ms-oriented) FIXED — 0.001 … 5, 10, 30, 60 (5 s sync cycle)
aether.replicator.sync.duration (unit s) registrar/internal/replicator/metrics.go seconds SDK default (ms-oriented) FIXED — 0.001 … 5, 10, 30, 60
aether.mesh_dns.query.duration (unit s) agent/internal/meshdns/metrics.go seconds explicit queryDurationBuckets 0.0001 … 5 already correct (verified, not assumed — this is why its p99 read a plausible 87.5 ms on 09-05)
aether.supervisor.handoff.duration (unit s) agent/internal/proxy/hotrestart/metrics.go seconds explicit 1, 5, 10, 30, 60, 120, 300 already correct
aether.supervisor.drain.duration (unit s) agent/internal/proxy/hotrestart/metrics.go seconds explicit 1, 5, 10, 30, 60, 120 already correct
aether.cni.operation.duration (unit s) cni/internal/telemetry/operations.go seconds explicit 0.05 … 10 already correct

No Int64Histogram exists anywhere in the repo; controller/ and registry/ register no
histograms at all.

Note the OTLP→Prometheus exporter appends the unit suffix, so the dot-named instruments
above all land in Prometheus as *_duration_seconds — the same trap, same fix.

Dashboards / hard-coded bucket labels

  • In this repo: nothing hard-codes an le value for any of these metrics. The only
    prober references are counter queries (aether_probe_requests_total) in
    e2e/soak/README.md, e2e/pressure/run.sh and docs/observability/mesh-dns-alerts.yml
    — unaffected. docs/proposals/013_mesh-availability-prober.md is updated to record the
    explicit boundaries as part of the metric's contract.
  • GitOps (k8s-talos-main, read-only from here): grep -rn aether_probe_request_duration
    returns nothing — no Grafana panel or alert rule consumes the prober histogram today,
    so no le label changes are required there. The only le-bearing aether rule is
    MeshDNSAuthoritativeSlow in clusters/talos-main/prometheus/values.yaml:481
    (histogram_quantile(0.99, sum by (le, node)(rate(aether_mesh_dns_query_duration_seconds_bucket{result="answered"}[10m]))) > 0.15)
    — it reads the mesh-DNS histogram, whose buckets are unchanged by this PR, so the 150 ms
    threshold keeps its meaning. Whoever adds prober latency panels should now be able to,
    which was the point.

Validation

  • bazel test --test_arg=-test.short //prober/... //common/... //agent/internal/meshdns/... — pass
  • bazel test --test_arg=-test.short //agent/internal/xds/cache/... //agent/internal/cni/... //registrar/... //cni/... — pass (every touched package)
  • make gazelle, make format-check — clean. No dependency changes.
  • No charts/ change: the prober chart is version-stamped per commit.

After deploying the prober chart, this should read in milliseconds, not 0 or 5:

histogram_quantile(0.99, sum by (le) (rate(aether_probe_request_duration_seconds_bucket{tier="mesh_dns"}[5m])))

and the timeout tail should now be visible as its own bucket rather than folded into le=5:

sum by (le) (rate(aether_probe_request_duration_seconds_bucket{tier="mesh_dns"}[5m]))

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…onds buckets (#732)

aether_probe_request_duration_seconds records time.Since(start).Seconds() but
took the OTel SDK's default explicit boundaries (0, 5, 10, 25 ... 10000), which
are tuned for MILLISECONDS. With seconds-valued observations the first bucket is
"<= 5 s", so a healthy 2 ms probe and a timed-out 2 s probe are the same bucket:
control-tested on talos, all 18,394 pre-fix ~2 s timeout observations on one
prober sit in le=5, identical to +Inf, and every derived quantile reads flat.

Set explicit seconds boundaries on the instrument
(metric.WithExplicitBucketBoundaries, honoured by the pinned otel metric v1.44 --
no View needed), chosen so healthy sub-10 ms probes, the 1 s resolver retransmit
(#728), the 2 s probe budget and the 5 s legacy retransmit each land in their own
bucket. Name and unit are unchanged.

Swept every histogram in the repo for the same mistake and fixed the three others
that recorded seconds into the millisecond defaults:
aether.agent.snapshot.duration, aether.agent.liveness.promotion_delay_seconds,
aether.registrar.sync.duration and aether.replicator.sync.duration. mesh-DNS,
the supervisor and the CNI plugin already carried explicit boundaries.

The prober test asserts the boundaries on the EXPORTED data point via an
sdkmetric ManualReader, so it covers the option actually reaching the SDK, and
pins that a 2.0 s observation lands in le=2 and not in le=1.5.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 6b1d5a3 into main Sep 6, 2026
18 checks passed
@bpalermo
bpalermo deleted the fix/732-histogram-buckets branch September 6, 2026 14:43
bpalermo added a commit that referenced this pull request Sep 6, 2026
…roven serving (#729) (#734)

On an `aether-mesh-dns` roll (maxSurge:1/maxUnavailable:0, SO_REUSEPORT,
readiness initialDelaySeconds:1, no preStop, no drain) the DaemonSet controller
deletes the predecessor the instant the successor passes its first readiness
probe, and `Server.Start` closed the UDP+TCP sockets on the resulting SIGTERM.
Every datagram the kernel had already steered into the departing socket's queue
was discarded. #726 Phase 1 traced a 5.106 s hole in the mesh-domain access log
to exactly one such lost query: Go's resolver singleflights by name, so one drop
stalls every concurrent lookup of that name for a full retransmit timeout.
#728 shrank that to ~1 s from the client side; the datagram loss was untouched.

Lame duck. On SIGTERM the resolver now removes its ready marker (the pod reports
NotReady, which is honest — it IS leaving) and KEEPS SERVING until either a
successor is observed answering on the same address or `--lame-duck-max`
(default 10s) elapses; only then does it close and exit 0.

Successor detection is evidence, not a timer. The resolver answers a reserved
identity name, `_instance._aether.<mesh-domain>` TXT, with 64 random bits minted
at process start — random, because predecessor and successor are each pid 1 in
their own container, so a pid stamp could never tell them apart. The lame duck
queries that name OVER THE WIRE at its own listen address every 200 ms. Both
processes hold a socket in the reuseport group, so the kernel hashes each probe
(fresh source port, fresh hash) at one of them; a reply carrying someone else's
stamp proves both halves of what must be true before closing — the successor is
IN the group and it ANSWERS. Our own stamp, or no reply, is "not yet".

A second SIGTERM cuts the window short (reason=signal); the handler is
registered only after the shutdown begins, so the first signal can never be
mistaken for it.

Residual, stated in the code and unfixable from userspace: close() on a
reuseport socket can still discard a datagram queued between the last recvfrom
and the close. eBPF sk_reuseport steering would be the complete fix. This
narrows the exposure from every roll to that instant.

Metrics: aether.mesh_dns.lame_duck.exits{reason=successor|deadline|signal} and
aether.mesh_dns.lame_duck.duration (seconds, EXPLICIT seconds buckets — the
mistake #732/#733 just swept out of the repo). The histogram builder now
requires boundaries rather than defaulting, so the next instrument cannot repeat
it. INFO lines: "lame duck started", "successor observed" (both stamps),
"lame duck deadline reached", "listener closed".

Chart 0.92.7 -> 0.92.8: `agent.meshDnsDaemon.lameDuckMax` (default "10s") and a
terminationGracePeriodSeconds DERIVED from it (+5s) so the kubelet can never
SIGKILL mid-window; no preStop, since the process handles SIGTERM itself.
maxSurge:1/maxUnavailable:0 unchanged.


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant