prometheus/retrieval/scrape.go
Fabian Reinartz 5bfa4cdd46 Simplify target update handling.
We group providers by their scrape configuration. Each provider produces
target groups with an unique identifier.

On stopping a set of target providers we cancel the target providers,
stop scraping the targets and wait for the scrapers to finish.

On configuration reload all provider sets are stopped and new ones
are created. This will make targets disappear briefly on configuration
reload. Potentially scrapes are missed but due to the consistent
scrape intervals implemented recently, the impact is minor.
2016-03-01 13:48:36 +01:00

78 lines
1.8 KiB
Go

// Copyright 2016 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package retrieval
// import (
// "sync"
// "time"
// "github.com/prometheus/common/log"
// "github.com/prometheus/common/model"
// "golang.org/x/net/context"
// "github.com/prometheus/prometheus/config"
// "github.com/prometheus/prometheus/storage"
// )
// type scraper interface {
// scrape(context.Context) error
// report(start time.Time, dur time.Duration, err error) error
// }
// type scrapePool struct {
// mtx sync.RWMutex
// targets map[model.Fingerprint]*Target
// loops map[model.Fingerprint]loop
// config *config.ScrapeConfig
// newLoop func(context.Context)
// }
// func newScrapePool(c *config.ScrapeConfig) *scrapePool {
// return &scrapePool{config: c}
// }
// func (sp *scrapePool) sync(targets []*Target) {
// sp.mtx.Lock()
// defer sp.mtx.Unlock()
// uniqueTargets := make(map[string]*Target{}, len(targets))
// for _, t := range targets {
// uniqueTargets[t.fingerprint()] = t
// }
// sp.targets = uniqueTargets
// }
// type scrapeLoop struct {
// scraper scraper
// mtx sync.RWMutex
// }
// func newScrapeLoop(ctx context.Context)
// func (sl *scrapeLoop) update() {}
// func (sl *scrapeLoop) run(ctx context.Context) {
// var wg sync.WaitGroup
// wg.Wait()
// }
// func (sl *scrapeLoop) stop() {
// }