startMetricsMonitoring starts a goroutine that periodically updates compaction metrics by taking a snapshot of the queue and counting tasks per hook.
()
| 691 | // startMetricsMonitoring starts a goroutine that periodically updates compaction metrics |
| 692 | // by taking a snapshot of the queue and counting tasks per hook. |
| 693 | func (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 |
| 717 | func (q *TaskQueue) updateCompactionMetrics() { |
no test coverage detected