From b75428ec19d6f49dbf23f11510e3411fb7df35d7 Mon Sep 17 00:00:00 2001 From: Krasi Georgiev Date: Thu, 1 Feb 2018 09:55:07 +0000 Subject: [PATCH] rename package retrieve to scrape no fucnctinal changes just renaming retrieval to scrape --- cmd/prometheus/main.go | 4 ++-- discovery/file/file.go | 2 +- pkg/relabel/relabel.go | 2 +- relabel/relabel.go | 2 +- {retrieval => scrape}/helpers_test.go | 2 +- {retrieval => scrape}/manager.go | 2 +- {retrieval => scrape}/manager_test.go | 2 +- {retrieval => scrape}/scrape.go | 2 +- {retrieval => scrape}/scrape_test.go | 2 +- {retrieval => scrape}/target.go | 2 +- {retrieval => scrape}/target_test.go | 2 +- .../testdata/bearertoken.txt | 0 {retrieval => scrape}/testdata/ca.cer | 0 {retrieval => scrape}/testdata/ca.key | 0 {retrieval => scrape}/testdata/client.cer | 0 {retrieval => scrape}/testdata/client.key | 0 {retrieval => scrape}/testdata/server.cer | 0 {retrieval => scrape}/testdata/server.key | 0 {retrieval => scrape}/testdata/servername.cer | 0 {retrieval => scrape}/testdata/servername.key | 0 storage/remote/write.go | 2 +- web/api/v1/api.go | 10 ++++---- web/api/v1/api_test.go | 12 +++++----- web/api/v2/api.go | 6 ++--- web/web.go | 24 +++++++++---------- 25 files changed, 39 insertions(+), 39 deletions(-) rename {retrieval => scrape}/helpers_test.go (99%) rename {retrieval => scrape}/manager.go (99%) rename {retrieval => scrape}/manager_test.go (99%) rename {retrieval => scrape}/scrape.go (99%) rename {retrieval => scrape}/scrape_test.go (99%) rename {retrieval => scrape}/target.go (99%) rename {retrieval => scrape}/target_test.go (99%) rename {retrieval => scrape}/testdata/bearertoken.txt (100%) rename {retrieval => scrape}/testdata/ca.cer (100%) rename {retrieval => scrape}/testdata/ca.key (100%) rename {retrieval => scrape}/testdata/client.cer (100%) rename {retrieval => scrape}/testdata/client.key (100%) rename {retrieval => scrape}/testdata/server.cer (100%) rename {retrieval => scrape}/testdata/server.key (100%) rename {retrieval => scrape}/testdata/servername.cer (100%) rename {retrieval => scrape}/testdata/servername.key (100%) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index c090313b9..c60a0c335 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -50,8 +50,8 @@ import ( sd_config "github.com/prometheus/prometheus/discovery/config" "github.com/prometheus/prometheus/notifier" "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/retrieval" "github.com/prometheus/prometheus/rules" + "github.com/prometheus/prometheus/scrape" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage/remote" "github.com/prometheus/prometheus/storage/tsdb" @@ -246,7 +246,7 @@ func main() { ctxNotify, cancelNotify = context.WithCancel(context.Background()) discoveryManagerNotify = discovery.NewManager(ctxNotify, log.With(logger, "component", "discovery manager notify")) - scrapeManager = retrieval.NewManager(log.With(logger, "component", "scrape manager"), fanoutStorage) + scrapeManager = scrape.NewManager(log.With(logger, "component", "scrape manager"), fanoutStorage) queryEngine = promql.NewEngine(fanoutStorage, &cfg.queryEngine) ruleManager = rules.NewManager(&rules.ManagerOptions{ Appendable: fanoutStorage, diff --git a/discovery/file/file.go b/discovery/file/file.go index eaba2df6f..cf1e1deb0 100644 --- a/discovery/file/file.go +++ b/discovery/file/file.go @@ -389,7 +389,7 @@ func (d *Discovery) readFile(filename string) ([]*targetgroup.Group, error) { return nil, err } default: - panic(fmt.Errorf("retrieval.FileDiscovery.readFile: unhandled file extension %q", ext)) + panic(fmt.Errorf("discovery.File.readFile: unhandled file extension %q", ext)) } for i, tg := range targetGroups { diff --git a/pkg/relabel/relabel.go b/pkg/relabel/relabel.go index 775051474..4f215ca7f 100644 --- a/pkg/relabel/relabel.go +++ b/pkg/relabel/relabel.go @@ -96,7 +96,7 @@ func relabel(lset labels.Labels, cfg *config.RelabelConfig) labels.Labels { } } default: - panic(fmt.Errorf("retrieval.relabel: unknown relabel action type %q", cfg.Action)) + panic(fmt.Errorf("relabel: unknown relabel action type %q", cfg.Action)) } return lb.Labels() diff --git a/relabel/relabel.go b/relabel/relabel.go index 49e134c13..d506620f1 100644 --- a/relabel/relabel.go +++ b/relabel/relabel.go @@ -99,7 +99,7 @@ func relabel(labels model.LabelSet, cfg *config.RelabelConfig) model.LabelSet { } } default: - panic(fmt.Errorf("retrieval.relabel: unknown relabel action type %q", cfg.Action)) + panic(fmt.Errorf("relabel: unknown relabel action type %q", cfg.Action)) } return labels } diff --git a/retrieval/helpers_test.go b/scrape/helpers_test.go similarity index 99% rename from retrieval/helpers_test.go rename to scrape/helpers_test.go index 018bf9c19..f1e5471df 100644 --- a/retrieval/helpers_test.go +++ b/scrape/helpers_test.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "github.com/prometheus/prometheus/pkg/labels" diff --git a/retrieval/manager.go b/scrape/manager.go similarity index 99% rename from retrieval/manager.go rename to scrape/manager.go index 3fb88cb7b..356f1d862 100644 --- a/retrieval/manager.go +++ b/scrape/manager.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "fmt" diff --git a/retrieval/manager_test.go b/scrape/manager_test.go similarity index 99% rename from retrieval/manager_test.go rename to scrape/manager_test.go index a4f2df96e..94d2f41f6 100644 --- a/retrieval/manager_test.go +++ b/scrape/manager_test.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "fmt" diff --git a/retrieval/scrape.go b/scrape/scrape.go similarity index 99% rename from retrieval/scrape.go rename to scrape/scrape.go index d13aa3b2b..5c5a71b00 100644 --- a/retrieval/scrape.go +++ b/scrape/scrape.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "bufio" diff --git a/retrieval/scrape_test.go b/scrape/scrape_test.go similarity index 99% rename from retrieval/scrape_test.go rename to scrape/scrape_test.go index b63959767..61284059b 100644 --- a/retrieval/scrape_test.go +++ b/scrape/scrape_test.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "bytes" diff --git a/retrieval/target.go b/scrape/target.go similarity index 99% rename from retrieval/target.go rename to scrape/target.go index 900ddb632..948d86136 100644 --- a/retrieval/target.go +++ b/scrape/target.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "errors" diff --git a/retrieval/target_test.go b/scrape/target_test.go similarity index 99% rename from retrieval/target_test.go rename to scrape/target_test.go index a21f3fcbf..bee0ad1eb 100644 --- a/retrieval/target_test.go +++ b/scrape/target_test.go @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package retrieval +package scrape import ( "crypto/tls" diff --git a/retrieval/testdata/bearertoken.txt b/scrape/testdata/bearertoken.txt similarity index 100% rename from retrieval/testdata/bearertoken.txt rename to scrape/testdata/bearertoken.txt diff --git a/retrieval/testdata/ca.cer b/scrape/testdata/ca.cer similarity index 100% rename from retrieval/testdata/ca.cer rename to scrape/testdata/ca.cer diff --git a/retrieval/testdata/ca.key b/scrape/testdata/ca.key similarity index 100% rename from retrieval/testdata/ca.key rename to scrape/testdata/ca.key diff --git a/retrieval/testdata/client.cer b/scrape/testdata/client.cer similarity index 100% rename from retrieval/testdata/client.cer rename to scrape/testdata/client.cer diff --git a/retrieval/testdata/client.key b/scrape/testdata/client.key similarity index 100% rename from retrieval/testdata/client.key rename to scrape/testdata/client.key diff --git a/retrieval/testdata/server.cer b/scrape/testdata/server.cer similarity index 100% rename from retrieval/testdata/server.cer rename to scrape/testdata/server.cer diff --git a/retrieval/testdata/server.key b/scrape/testdata/server.key similarity index 100% rename from retrieval/testdata/server.key rename to scrape/testdata/server.key diff --git a/retrieval/testdata/servername.cer b/scrape/testdata/servername.cer similarity index 100% rename from retrieval/testdata/servername.cer rename to scrape/testdata/servername.cer diff --git a/retrieval/testdata/servername.key b/scrape/testdata/servername.key similarity index 100% rename from retrieval/testdata/servername.key rename to scrape/testdata/servername.key diff --git a/storage/remote/write.go b/storage/remote/write.go index 2687b9d83..7427b3bbb 100644 --- a/storage/remote/write.go +++ b/storage/remote/write.go @@ -19,7 +19,7 @@ import ( "github.com/prometheus/prometheus/storage" ) -// Appender implements retrieval.Appendable. +// Appender implements scrape.Appendable. func (s *Storage) Appender() (storage.Appender, error) { return s, nil } diff --git a/web/api/v1/api.go b/web/api/v1/api.go index e18137d06..523316c90 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -38,7 +38,7 @@ import ( "github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/retrieval" + "github.com/prometheus/prometheus/scrape" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/storage/remote" "github.com/prometheus/prometheus/util/httputil" @@ -82,7 +82,7 @@ func (e *apiError) Error() string { } type targetRetriever interface { - Targets() []*retrieval.Target + Targets() []*scrape.Target } type alertmanagerRetriever interface { @@ -428,9 +428,9 @@ type Target struct { ScrapeURL string `json:"scrapeUrl"` - LastError string `json:"lastError"` - LastScrape time.Time `json:"lastScrape"` - Health retrieval.TargetHealth `json:"health"` + LastError string `json:"lastError"` + LastScrape time.Time `json:"lastScrape"` + Health scrape.TargetHealth `json:"health"` } // TargetDiscovery has all the active targets. diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 425e0aafb..9b6ebe542 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -38,13 +38,13 @@ import ( "github.com/prometheus/prometheus/pkg/timestamp" "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/retrieval" + "github.com/prometheus/prometheus/scrape" "github.com/prometheus/prometheus/storage/remote" ) -type targetRetrieverFunc func() []*retrieval.Target +type targetRetrieverFunc func() []*scrape.Target -func (f targetRetrieverFunc) Targets() []*retrieval.Target { +func (f targetRetrieverFunc) Targets() []*scrape.Target { return f() } @@ -81,9 +81,9 @@ func TestEndpoints(t *testing.T) { now := time.Now() - tr := targetRetrieverFunc(func() []*retrieval.Target { - return []*retrieval.Target{ - retrieval.NewTarget( + tr := targetRetrieverFunc(func() []*scrape.Target { + return []*scrape.Target{ + scrape.NewTarget( labels.FromMap(map[string]string{ model.SchemeLabel: "http", model.AddressLabel: "example.com:8080", diff --git a/web/api/v2/api.go b/web/api/v2/api.go index 79c73831b..ff97661d9 100644 --- a/web/api/v2/api.go +++ b/web/api/v2/api.go @@ -40,7 +40,7 @@ import ( "github.com/prometheus/prometheus/pkg/timestamp" pb "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/retrieval" + "github.com/prometheus/prometheus/scrape" "github.com/prometheus/prometheus/storage" ) @@ -50,7 +50,7 @@ type API struct { now func() time.Time db func() *tsdb.DB q func(ctx context.Context, mint, maxt int64) (storage.Querier, error) - targets func() []*retrieval.Target + targets func() []*scrape.Target alertmanagers func() []*url.URL } @@ -60,7 +60,7 @@ func New( db func() *tsdb.DB, qe *promql.Engine, q func(ctx context.Context, mint, maxt int64) (storage.Querier, error), - targets func() []*retrieval.Target, + targets func() []*scrape.Target, alertmanagers func() []*url.URL, enableAdmin bool, ) *API { diff --git a/web/web.go b/web/web.go index 5271db67e..0a4ee7500 100644 --- a/web/web.go +++ b/web/web.go @@ -55,8 +55,8 @@ import ( "github.com/prometheus/prometheus/notifier" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/retrieval" "github.com/prometheus/prometheus/rules" + "github.com/prometheus/prometheus/scrape" "github.com/prometheus/prometheus/storage" "github.com/prometheus/prometheus/template" "github.com/prometheus/prometheus/util/httputil" @@ -71,7 +71,7 @@ var localhostRepresentations = []string{"127.0.0.1", "localhost"} type Handler struct { logger log.Logger - scrapeManager *retrieval.ScrapeManager + scrapeManager *scrape.ScrapeManager ruleManager *rules.Manager queryEngine *promql.Engine context context.Context @@ -125,7 +125,7 @@ type Options struct { TSDB func() *tsdb.DB Storage storage.Storage QueryEngine *promql.Engine - ScrapeManager *retrieval.ScrapeManager + ScrapeManager *scrape.ScrapeManager RuleManager *rules.Manager Notifier *notifier.Manager Version *PrometheusVersion @@ -404,7 +404,7 @@ func (h *Handler) Run(ctx context.Context) error { h.options.TSDB, h.options.QueryEngine, h.options.Storage.Querier, - func() []*retrieval.Target { + func() []*scrape.Target { return h.options.ScrapeManager.Targets() }, func() []*url.URL { @@ -594,7 +594,7 @@ func (h *Handler) serviceDiscovery(w http.ResponseWriter, r *http.Request) { sort.Strings(index) scrapeConfigData := struct { Index []string - Targets map[string][]*retrieval.Target + Targets map[string][]*scrape.Target }{ Index: index, Targets: targets, @@ -604,7 +604,7 @@ func (h *Handler) serviceDiscovery(w http.ResponseWriter, r *http.Request) { func (h *Handler) targets(w http.ResponseWriter, r *http.Request) { // Bucket targets by job label - tps := map[string][]*retrieval.Target{} + tps := map[string][]*scrape.Target{} for _, t := range h.scrapeManager.Targets() { job := t.Labels().Get(model.JobLabel) tps[job] = append(tps[job], t) @@ -617,7 +617,7 @@ func (h *Handler) targets(w http.ResponseWriter, r *http.Request) { } h.executeTemplate(w, "targets.html", struct { - TargetPools map[string][]*retrieval.Target + TargetPools map[string][]*scrape.Target }{ TargetPools: tps, }) @@ -707,21 +707,21 @@ func tmplFuncs(consolesPath string, opts *Options) template_text.FuncMap { } return u }, - "numHealthy": func(pool []*retrieval.Target) int { + "numHealthy": func(pool []*scrape.Target) int { alive := len(pool) for _, p := range pool { - if p.Health() != retrieval.HealthGood { + if p.Health() != scrape.HealthGood { alive-- } } return alive }, - "healthToClass": func(th retrieval.TargetHealth) string { + "healthToClass": func(th scrape.TargetHealth) string { switch th { - case retrieval.HealthUnknown: + case scrape.HealthUnknown: return "warning" - case retrieval.HealthGood: + case scrape.HealthGood: return "success" default: return "danger"