Example #1
0
func (m *targetManager) AddTarget(job config.JobConfig, t Target) {
	m.Lock()
	defer m.Unlock()

	targetPool := m.targetPoolForJob(job)
	targetPool.AddTarget(t)
	m.poolsByJob[job.GetName()] = targetPool
}
Example #2
0
func (m *targetManager) targetPoolForJob(job config.JobConfig) *TargetPool {
	targetPool, ok := m.poolsByJob[job.GetName()]

	if !ok {
		var provider TargetProvider
		if job.SdName != nil {
			provider = NewSdTargetProvider(job)
		}

		interval := job.ScrapeInterval()
		targetPool = NewTargetPool(m, provider, m.ingester, interval)
		glog.Infof("Pool for job %s does not exist; creating and starting...", job.GetName())

		m.poolsByJob[job.GetName()] = targetPool
		go targetPool.Run()
	}

	return targetPool
}
Example #3
0
func (m *targetManager) TargetPoolForJob(job config.JobConfig) *TargetPool {
	targetPool, ok := m.poolsByJob[job.GetName()]

	if !ok {
		var provider TargetProvider = nil
		if job.SdName != nil {
			provider = NewSdTargetProvider(job)
		}

		targetPool = NewTargetPool(m, provider)
		glog.Infof("Pool for job %s does not exist; creating and starting...", job.GetName())

		interval := job.ScrapeInterval()
		m.poolsByJob[job.GetName()] = targetPool
		// BUG(all): Investigate whether this auto-goroutine creation is desired.
		go targetPool.Run(m.ingester, interval)
	}

	return targetPool
}
Example #4
0
func (m *targetManager) AddTarget(job config.JobConfig, t Target) {
	targetPool := m.TargetPoolForJob(job)
	targetPool.AddTarget(t)
	m.poolsByJob[job.GetName()] = targetPool
}