func (d *dispatcher) updateRunnersStats() {
	if d.clcRunnersClient == nil {
		log.Debug("Cluster Level Check runner client was not correctly initialised")
		return
	}

	start := time.Now()
	defer func() {
		updateStatsDuration.Set(time.Since(start).Seconds(), le.JoinLeaderValue)
	}()

	d.store.Lock()
	defer d.store.Unlock()
	for name, node := range d.store.nodes {
		node.RLock()
		ip := node.clientIP
		node.RUnlock()

		stats, err := d.clcRunnersClient.GetRunnerStats(ip)
		if err != nil {
			log.Debugf("Cannot get CLC Runner stats with IP %s on node %s: %v", node.clientIP, name, err)
			statsCollectionFails.Inc(name, le.JoinLeaderValue)
			continue
		}
		node.Lock()
		for id, checkStats := range stats {
			// Stats contain info about all the running checks on a node
			// Node checks must be filtered from Cluster Checks
			// so they can be included in calculating node Agent busyness and excluded from rebalancing decisions.
			if _, found := d.store.idToDigest[check.ID(id)]; found {
				// Cluster check detected (exists in the Cluster Agent checks store)
				log.Tracef("Check %s running on node %s is a cluster check", id, node.name)
				checkStats.IsClusterCheck = true
				stats[id] = checkStats
			}
		}
		node.clcRunnerStats = stats
		log.Tracef("Updated CLC Runner stats on node: %s, node IP: %s, stats: %v", name, node.clientIP, stats)
		node.busyness = calculateBusyness(stats)
		log.Debugf("Updated busyness on node: %s, node IP: %s, busyness value: %d", name, node.clientIP, node.busyness)
		busyness.Set(float64(node.busyness), node.name, le.JoinLeaderValue)
		node.Unlock()
	}
}
// updateRunnersStats collects stats from the registred
// Cluster Level Check runners and updates the stats cache
updateRunnersStats collects stats from the registred
Cluster Level Check runners and updates the stats cache
// updateRunnersStats collects stats from the registred // Cluster Level Check runners and updates the stats cache
func (d *dispatcher) updateRunnersStats() {
	if d.clcRunnersClient == nil {
		log.Debug("Cluster Level Check runner client was not correctly initialised")
		return
	}
	start := time.Now()
	defer func() {
		updateStatsDuration.Set(time.Since(start).Seconds(), le.JoinLeaderValue)
	}()
	d.store.Lock()
	defer d.store.Unlock()
	for name, node := range d.store.nodes {
		node.RLock()
		ip := node.clientIP
		node.RUnlock()
		stats, err := d.clcRunnersClient.GetRunnerStats(ip)
		if err != nil {
			log.Debugf("Cannot get CLC Runner stats with IP %s on node %s: %v", node.clientIP, name, err)
			statsCollectionFails.Inc(name, le.JoinLeaderValue)
			continue
		}
		node.Lock()
		for id, checkStats := range stats {
			if _, found := d.store.idToDigest[check.ID(id)]; found {
				log.Tracef("Check %s running on node %s is a cluster check", id, node.name)
				checkStats.IsClusterCheck = true
				stats[id] = checkStats
			}
		}
		node.clcRunnerStats = stats
		log.Tracef("Updated CLC Runner stats on node: %s, node IP: %s, stats: %v", name, node.clientIP, stats)
		node.busyness = calculateBusyness(stats)
		log.Debugf("Updated busyness on node: %s, node IP: %s, busyness value: %d", name, node.clientIP, node.busyness)
		busyness.Set(float64(node.busyness), node.name, le.JoinLeaderValue)
		node.Unlock()
	}
}
func ( d * dispatcher ) updateRunnersStats ( ) { if d . clcRunnersClient == nil { log . Debug ( " " ) return } start := time . Now ( ) defer func ( ) { updateStatsDuration . Set ( time . Since ( start ) . Seconds ( ) , le . JoinLeaderValue ) } ( ) d . store . Lock ( ) defer d . store . Unlock ( ) for name , node := range d . store . nodes { node . RLock ( ) ip := node . clientIP node . RUnlock ( ) stats , err := d . clcRunnersClient . GetRunnerStats ( ip ) if err != nil { log . Debugf ( " " , node . clientIP , name , err ) statsCollectionFails . Inc ( name , le . JoinLeaderValue ) continue } node . Lock ( ) for id , checkStats := range stats { if _ , found := d . store . idToDigest [ check . ID ( id ) ] ; found { log . Tracef ( " " , id , node . name ) checkStats . IsClusterCheck = true stats [ id ] = checkStats } } node . clcRunnerStats = stats log . Tracef ( " " , name , node . clientIP , stats ) node . busyness = calculateBusyness ( stats ) log . Debugf ( " " , name , node . clientIP , node . busyness ) busyness . Set ( float64 ( node . busyness ) , node . name , le . JoinLeaderValue ) node . Unlock ( ) } }
updateRunnersStats collects stats from the registred
Cluster Level Check runners and updates the stats cache
updateRunnersStats collects stats from the registred Cluster Level Check runners and updates the stats cache
// Stats contain info about all the running checks on a node // Node checks must be filtered from Cluster Checks // so they can be included in calculating node Agent busyness and excluded from rebalancing decisions. // Cluster check detected (exists in the Cluster Agent checks store)