From 5c43db466a3b72dec8fa55c09fa4c5a41c695e60 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 27 Apr 2026 15:03:36 -0700 Subject: [PATCH] Fix crashing when removing hc --- healthcheck/healthcheck.go | 6 +++--- main.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/healthcheck/healthcheck.go b/healthcheck/healthcheck.go index a7f0b6a..0f3a039 100644 --- a/healthcheck/healthcheck.go +++ b/healthcheck/healthcheck.go @@ -250,7 +250,7 @@ func (m *Monitor) RemoveTarget(id int) error { // Notify callback of status change if m.callback != nil { - go m.callback(m.GetTargets()) + go m.callback(m.getAllTargetsUnsafe()) } logger.Info("Successfully removed target %d", id) @@ -283,7 +283,7 @@ func (m *Monitor) RemoveTargets(ids []int) error { // Notify callback of status change if any targets were removed if len(notFound) != len(ids) && m.callback != nil { - go m.callback(m.GetTargets()) + go m.callback(m.getAllTargetsUnsafe()) } if len(notFound) > 0 { @@ -583,7 +583,7 @@ func (m *Monitor) DisableTarget(id int) error { // Notify callback of status change if m.callback != nil { - go m.callback(m.GetTargets()) + go m.callback(m.getAllTargetsUnsafe()) } } else { logger.Debug("Target %d is already disabled", id) diff --git a/main.go b/main.go index 7718c5d..448f71d 100644 --- a/main.go +++ b/main.go @@ -542,7 +542,7 @@ func runNewtMain(ctx context.Context) { if telErr != nil { logger.Warn("Telemetry init failed: %v", telErr) } - if tel != nil { + if tel != nil && (metricsEnabled || pprofEnabled) { // Admin HTTP server (exposes /metrics when Prometheus exporter is enabled) logger.Debug("Starting metrics server on %s", tcfg.AdminAddr) mux := http.NewServeMux()