Skip to content

[log] log: add debug logging to health monitor#3265

Merged
lpcox merged 1 commit intomainfrom
log/health-monitor-debug-logging-bad2700a5eeef8c4
Apr 6, 2026
Merged

[log] log: add debug logging to health monitor#3265
lpcox merged 1 commit intomainfrom
log/health-monitor-debug-logging-bad2700a5eeef8c4

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 6, 2026

Summary

Adds 6 meaningful debug log calls to internal/launcher/health_monitor.go using the existing logHealth logger (launcher:health namespace).

Changes

File modified: internal/launcher/health_monitor.go

Function Added logging
NewHealthMonitor Log creation with configured interval and max restart failures constant
Stop Log when stop is initiated (before blocking on doneCh)
run Log goroutine startup with interval
checkAll Log total server count each health check cycle
checkAll Log when a recovered server's failure counter is reset (server came back healthy)
handleErrorState Log when max restart failures reached and restart is silently skipped

Why These Additions?

The health monitor is a critical background component that manages server recovery. Without debug logging, it's difficult to answer questions like:

  • When was the health monitor created and with what interval?
  • Is the goroutine actually running?
  • How many servers are being checked each cycle?
  • Did a server recover and when?
  • Why is a failed server not being restarted (max failures reached)?

Quality Checklist

  • Exactly 1 file modified
  • No test files modified
  • Reuses existing logHealth logger (no new declaration needed)
  • Logger naming follows pkg:filename convention (launcher:health)
  • No side effects in log arguments
  • Logging messages are meaningful and helpful
  • No duplicate logging with existing logs
  • 6 focused logging calls (within 3-7 guideline)

Generated by Go Logger Enhancement · ● 8.4M ·

Add 6 meaningful debug log calls to internal/launcher/health_monitor.go
using the existing logHealth logger (launcher:health namespace):

- NewHealthMonitor: log creation with interval and max restart failures
- Stop: log when stop is initiated (before blocking on doneCh)
- run: log goroutine startup with interval
- checkAll: log total servers being checked each cycle
- checkAll: log when a recovered server's failure counter is reset
- handleErrorState: log when max failures reached and restart is skipped

These additions improve troubleshooting of health monitoring behavior
during development and production incident investigation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Apr 6, 2026
@lpcox lpcox marked this pull request as ready for review April 6, 2026 14:42
Copilot AI review requested due to automatic review settings April 6, 2026 14:42
@lpcox lpcox merged commit 0442caf into main Apr 6, 2026
3 checks passed
@lpcox lpcox deleted the log/health-monitor-debug-logging-bad2700a5eeef8c4 branch April 6, 2026 14:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds debug-level logging to the launcher health monitor to improve observability during periodic health checks and server auto-restart behavior.

Changes:

  • Log health monitor creation with configured interval and restart-failure threshold.
  • Add debug logs around lifecycle events (stop initiation, goroutine start).
  • Add debug logs during health-check cycles (server count, recovery/reset, skip-restart at max failures).
Show a summary per file
File Description
internal/launcher/health_monitor.go Adds launcher:health debug logs for monitor lifecycle and health-check activity.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines 106 to 109
if failures >= maxConsecutiveRestartFailures {
// Already logged when the threshold was reached; stay silent.
logHealth.Printf("Skipping restart for serverID=%s: max failures reached (%d/%d)", serverID, failures, maxConsecutiveRestartFailures)
return
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The failures >= maxConsecutiveRestartFailures branch is documented as “stay silent” and the PR description says the restart is “silently skipped”, but this adds a debug log that will fire on every health-check tick for a permanently-failed server (potential log spam when DEBUG enables launcher:health). Consider removing this log, or only logging once at the moment the threshold is reached (and keep the comment/PR description consistent).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants