MCPcopy Index your code
hub / github.com/flant/shell-operator / startMetricsMonitoring

Method startMetricsMonitoring

pkg/task/queue/task_queue.go:693–714  ·  view source on GitHub ↗

startMetricsMonitoring starts a goroutine that periodically updates compaction metrics by taking a snapshot of the queue and counting tasks per hook.

()

Source from the content-addressed store, hash-verified

691// startMetricsMonitoring starts a goroutine that periodically updates compaction metrics
692// by taking a snapshot of the queue and counting tasks per hook.
693func (q *TaskQueue) startMetricsMonitoring() {
694 if q.metricStorage == nil || q.queueTasksCounter == nil {
695 return
696 }
697
698 go func() {
699 // Update metrics immediately on start
700 q.updateCompactionMetrics()
701
702 ticker := time.NewTicker(metricsMonitoringUpdateInterval)
703 defer ticker.Stop()
704
705 for {
706 select {
707 case <-q.ctx.Done():
708 return
709 case <-ticker.C:
710 q.updateCompactionMetrics()
711 }
712 }
713 }()
714}
715
716// updateCompactionMetrics counts tasks by hook and updates metrics
717func (q *TaskQueue) updateCompactionMetrics() {

Callers 1

StartMethod · 0.95

Calls 2

StopMethod · 0.65

Tested by

no test coverage detected