use baseName for prometheus
This commit is contained in:
		| @@ -2,6 +2,7 @@ package logmower | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
|  | 	"path/filepath" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/jtagcat/util" | 	"github.com/jtagcat/util" | ||||||
| @@ -77,8 +78,9 @@ func (s *submitter) sender(name string, sendQueue <-chan mLog) (synced func() bo | |||||||
| 		defer cancel() | 		defer cancel() | ||||||
|  |  | ||||||
| 		go func() { | 		go func() { | ||||||
|  | 			baseName := filepath.Base(name) | ||||||
| 			for { | 			for { | ||||||
| 				promShipperQueueItems.WithLabelValues(name).Observe(float64( | 				promShipperQueueItems.WithLabelValues(baseName).Observe(float64( | ||||||
| 					len(sendQueue))) | 					len(sendQueue))) | ||||||
|  |  | ||||||
| 				timer := time.NewTimer(time.Second) | 				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) { | func (s *submitter) senderRoutine(name string, batched <-chan []mLog, synced *bool) { | ||||||
| 	defer s.Done() | 	defer s.Done() | ||||||
|  |  | ||||||
|  | 	baseName := filepath.Base(name) | ||||||
|  |  | ||||||
| 	for { | 	for { | ||||||
| 		*synced = true | 		*synced = true | ||||||
| 		promShipperSynced.WithLabelValues(name).Set(1) | 		promShipperSynced.WithLabelValues(baseName).Set(1) | ||||||
|  |  | ||||||
| 		batch, ok := <-batched | 		batch, ok := <-batched | ||||||
| 		if !ok { | 		if !ok { | ||||||
| @@ -115,7 +119,7 @@ func (s *submitter) senderRoutine(name string, batched <-chan []mLog, synced *bo | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		*synced = false | 		*synced = false | ||||||
| 		promShipperSynced.WithLabelValues(name).Set(0) | 		promShipperSynced.WithLabelValues(baseName).Set(0) | ||||||
|  |  | ||||||
| 		var batchBson []interface{} // mongo does not like typing | 		var batchBson []interface{} // mongo does not like typing | ||||||
| 		for _, b := range batch { | 		for _, b := range batch { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user