Skip to content

Fix stats and beep bugs (reset race, history order, sort, beeper) - #83

Merged
servak merged 3 commits into
mainfrom
bugfix/stats-beep
Nov 8, 2026
Merged

servak merged 3 commits into
mainfrom
bugfix/stats-beep

Conversation

@servak

@servak servak commented Nov 8, 2026

Copy link
Copy Markdown
Owner

Bugs / fixes

  1. Reset race: metrics keep a reset time; results whose SentTime precedes it are dropped (counters, history, outage tracker, failure hook). Test: TestResetDropsStaleResults
  2. History arrival order: TargetHistory.AddEntry inserts by Timestamp (send time). Test: TestHistoryOrderedBySentTime
  3. LastSuccTime/LastFailTime/LastFailDetail keep the newest. Test: TestLastTimesKeepNewest
  4. MinimumRTT uses Successful==1 instead of 0 as unset. Test: TestMinimumRTTZeroSample
  5. SortBy iterates sorted keys and ties break by name then key. Test: TestSortDeterministicTies
  6. NewTargetHistory clamps size to >= 1 (NewMetrics(name, 0) no longer panics). Test: TestNewMetricsZeroHistorySize
  7. Beeper uses a single worker with a 1-slot channel (extra beeps dropped) and writes outside the lock. Test: TestBeepDoesNotBlockWhenOutputBlocked (adds an unexported out writer field)

No call-site changes outside internal/stats and internal/beep. go vet, go test -race ./..., golangci-lint pass.

@servak
servak merged commit c24d984 into main Nov 8, 2026
5 checks passed
@servak
servak deleted the bugfix/stats-beep branch November 8, 2026 07:44
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