func (sp *scrapePool) Sync(tgs []*targetgroup.Group) {
	start := time.Now()

	var all []*Target
	sp.mtx.Lock()
	sp.droppedTargets = []*Target{}
	for _, tg := range tgs {
		targets, err := targetsFromGroup(tg, sp.config)
		if err != nil {
			level.Error(sp.logger).Log("msg", "creating targets failed", "err", err)
			continue
		}
		for _, t := range targets {
			if t.Labels().Len() > 0 {
				all = append(all, t)
			} else if t.DiscoveredLabels().Len() > 0 {
				sp.droppedTargets = append(sp.droppedTargets, t)
			}
		}
	}
	sp.mtx.Unlock()
	sp.sync(all)

	targetSyncIntervalLength.WithLabelValues(sp.config.JobName).Observe(
		time.Since(start).Seconds(),
	)
	targetScrapePoolSyncsCounter.WithLabelValues(sp.config.JobName).Inc()
}
func (sp *scrapePool) Sync(tgs []*targetgroup.Group) {
	start := time.Now()

	var all []*Target
	sp.mtx.Lock()
	sp.droppedTargets = []*Target{}
	for _, tg := range tgs {
		targets, err := targetsFromGroup(tg, sp.config)
		if err != nil {
			level.Error(sp.logger).Log("msg", "creating targets failed", "err", err)
			continue
		}
		for _, t := range targets {
			if t.Labels().Len() > 0 {
				all = append(all, t)
			} else if t.DiscoveredLabels().Len() > 0 {
				sp.droppedTargets = append(sp.droppedTargets, t)
			}
		}
	}
	sp.mtx.Unlock()
	sp.sync(all)

	targetSyncIntervalLength.WithLabelValues(sp.config.JobName).Observe(
		time.Since(start).Seconds(),
	)
	targetScrapePoolSyncsCounter.WithLabelValues(sp.config.JobName).Inc()
}
func ( sp * scrapePool ) Sync ( tgs [ ] * targetgroup . Group ) { start := time . Now ( ) var all [ ] * Target sp . mtx . Lock ( ) sp . droppedTargets = [ ] * Target { } for _ , tg := range tgs { targets , err := targetsFromGroup ( tg , sp . config ) if err != nil { level . Error ( sp . logger ) . Log ( " " , " " , " " , err ) continue } for _ , t := range targets { if t . Labels ( ) . Len ( ) > 0 { all = append ( all , t ) } else if t . DiscoveredLabels ( ) . Len ( ) > 0 { sp . droppedTargets = append ( sp . droppedTargets , t ) } } } sp . mtx . Unlock ( ) sp . sync ( all ) targetSyncIntervalLength . WithLabelValues ( sp . config . JobName ) . Observe ( time . Since ( start ) . Seconds ( ) , ) targetScrapePoolSyncsCounter . WithLabelValues ( sp . config . JobName ) . Inc ( ) }
// Sync converts target groups into actual scrape targets and synchronizes
// the currently running scraper with the resulting set and returns all scraped and dropped targets.
Sync converts target groups into actual scrape targets and synchronizes the currently running scraper with the resulting set and returns all scraped and dropped targets .