Exemplo n.º 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
}
Exemplo n.º 2
0
// Constructs a new sdTargetProvider for a job.
func NewSdTargetProvider(job config.JobConfig) *sdTargetProvider {
	i, err := utility.StringToDuration(job.GetSdRefreshInterval())
	if err != nil {
		panic(fmt.Sprintf("illegal refresh duration string %s: %s", job.GetSdRefreshInterval(), err))
	}
	return &sdTargetProvider{
		job:             job,
		refreshInterval: i,
	}
}
Exemplo n.º 3
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
}
Exemplo n.º 4
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
}
Exemplo n.º 5
0
func (m *targetManager) AddTarget(job config.JobConfig, t Target) {
	targetPool := m.TargetPoolForJob(job)
	targetPool.AddTarget(t)
	m.poolsByJob[job.GetName()] = targetPool
}