From 270737516ccf9fcaaddc391a4fe92d57f1ae2bf6 Mon Sep 17 00:00:00 2001 From: rasmus Date: Sun, 6 Nov 2022 01:43:59 +0200 Subject: [PATCH] use baseName for prometheus --- cmd/sender.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/sender.go b/cmd/sender.go index 9897bb6..09f1481 100644 --- a/cmd/sender.go +++ b/cmd/sender.go @@ -2,6 +2,7 @@ package logmower import ( "context" + "path/filepath" "time" "github.com/jtagcat/util" @@ -77,8 +78,9 @@ func (s *submitter) sender(name string, sendQueue <-chan mLog) (synced func() bo defer cancel() go func() { + baseName := filepath.Base(name) for { - promShipperQueueItems.WithLabelValues(name).Observe(float64( + promShipperQueueItems.WithLabelValues(baseName).Observe(float64( len(sendQueue))) timer := time.NewTimer(time.Second) @@ -105,9 +107,11 @@ func (s *submitter) sender(name string, sendQueue <-chan mLog) (synced func() bo func (s *submitter) senderRoutine(name string, batched <-chan []mLog, synced *bool) { defer s.Done() + baseName := filepath.Base(name) + for { *synced = true - promShipperSynced.WithLabelValues(name).Set(1) + promShipperSynced.WithLabelValues(baseName).Set(1) batch, ok := <-batched if !ok { @@ -115,7 +119,7 @@ func (s *submitter) senderRoutine(name string, batched <-chan []mLog, synced *bo } *synced = false - promShipperSynced.WithLabelValues(name).Set(0) + promShipperSynced.WithLabelValues(baseName).Set(0) var batchBson []interface{} // mongo does not like typing for _, b := range batch {