feat(metrics): resync seq-gap histogram, drop per-resync logs - #42
Open
mikhail-dcl wants to merge 1 commit into
Open
feat(metrics): resync seq-gap histogram, drop per-resync logs#42mikhail-dcl wants to merge 1 commit into
mikhail-dcl wants to merge 1 commit into
Conversation
Replaces two per-resync log lines with a bucketed distribution of
latestSeq - knownSeq, split by outcome (targeted delta / STATE_FULL):
one merged percentile row on the console dashboard, and
dcl_pulse_resync_seq_gap{outcome} in Prometheus.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
Resync fallback to STATE_FULL for subject … (lastKnownSeq=…, gap=…)fired once per served resync at Warning, with a matching Information line beside it — too noisy to leave on, and the only useful signal in it was a single number.Change
That number is now a histogram:
latestSeq − knownSeqrecorded per served resync, bucketed dense aroundPeers:SnapshotHistoryCapacity(the ring-eviction cliff that decides targeted-delta vsSTATE_FULL), with a dedicated0edge so "client was already current" is distinguishable from "one publish behind".Split into
delta/fulloutcomes, so the fallback rate the oldLogWarningconveyed reads off thefullseries' own_count— no extra counter needed.Resync Seq Gaprow in the Latency group with the usual P50/P95/P99 window+lifetime columns, sparkline on window P99. Per-outcome split is Grafana-only, same convention asPeer RTT.dcl_pulse_resync_seq_gap{outcome="delta|full"}native histogram.ResyncRequestHandlerdrops toDebug— it fires 1:1 with the removed pair, so leaving it at Information would have kept the console just as noisy. Still available when chasing a single client.Follows the
delta_staleness/peer_rttpattern end to end;ResyncOutcome/ResyncOutcomesmirrors the existingConnectionClass/ConnectionClassesidiom.Note for review
ResyncRequest.KnownSeqis unvalidated client input —FieldValidatorhas no rule for it. The first cut used a serial-number cast,(int)(latestSeq - lastKnownSeq), to clamp a baseline ahead of the latest publish. That only disambiguates within 2^31: a client sendingknown_seq = 3_000_000_000against a smalllatestSeqrecorded a 1.29-billion sample, swamping_sumand the+Infbucket and faking the exact "sustained loss / stalled client" signal the docs tell operators to watch for.Now the ordering is tested before subtracting.
Seqdoesn't wrap within a session — it's server-assigned from 0 and reset to the sentinel on disconnect, the same assumption every otherSeqcomparison inPeerSimulationalready makes with plain</>.Testing
660 tests pass. New coverage: gap magnitude on both outcomes, outcome routing in the collector, Prometheus label/bucket shape, the already-current case, and four
TestCases across the ahead-baseline range (two of which fail against the pre-fix arithmetic).🤖 Generated with Claude Code