From 9dfebf6d88a01ec8d50b26579193b186a914c8c6 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sat, 16 May 2020 10:57:51 +0100
Subject: [PATCH] Initialize all counters at startup

---
 hark.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hark.go b/hark.go
index 763c0c4..0a58123 100644
--- a/hark.go
+++ b/hark.go
@@ -48,6 +48,10 @@ func hark(ports []int, stopCh chan struct{}) error {
 		}
 		listeners = append(listeners, l)
 
+		// Reset the counter explicitly so the metrics appear even
+		// before the first connection.
+		connections.WithLabelValues(strconv.Itoa(port)).Add(0)
+
 		wg.Add(1)
 		go func(port int) {
 			listener(l, port)
-- 
GitLab