use baseName for prometheus

This commit is contained in:
rasmus 2022-11-06 01:43:59 +02:00
parent e2b232ba63
commit 270737516c
1 changed files with 7 additions and 3 deletions

View File

@ -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 {