|
|
|
|
@ -49,6 +49,7 @@ import ( |
|
|
|
|
"github.com/prometheus/prometheus/model/value" |
|
|
|
|
"github.com/prometheus/prometheus/storage" |
|
|
|
|
"github.com/prometheus/prometheus/tsdb/chunkenc" |
|
|
|
|
"github.com/prometheus/prometheus/util/pool" |
|
|
|
|
"github.com/prometheus/prometheus/util/teststorage" |
|
|
|
|
"github.com/prometheus/prometheus/util/testutil" |
|
|
|
|
) |
|
|
|
|
@ -68,7 +69,7 @@ func TestNewScrapePool(t *testing.T) { |
|
|
|
|
var ( |
|
|
|
|
app = &nopAppendable{} |
|
|
|
|
cfg = &config.ScrapeConfig{} |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if a, ok := sp.appendable.(*nopAppendable); !ok || a != app { |
|
|
|
|
@ -104,7 +105,7 @@ func TestDroppedTargetsList(t *testing.T) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
expectedLabelSetString = "{__address__=\"127.0.0.1:9090\", __scrape_interval__=\"0s\", __scrape_timeout__=\"0s\", job=\"dropMe\"}" |
|
|
|
|
expectedLength = 2 |
|
|
|
|
) |
|
|
|
|
@ -504,7 +505,7 @@ func TestScrapePoolTargetLimit(t *testing.T) { |
|
|
|
|
func TestScrapePoolAppender(t *testing.T) { |
|
|
|
|
cfg := &config.ScrapeConfig{} |
|
|
|
|
app := &nopAppendable{} |
|
|
|
|
sp, _ := newScrapePool(cfg, app, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, _ := newScrapePool(cfg, app, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
|
|
|
|
|
loop := sp.newLoop(scrapeLoopOptions{ |
|
|
|
|
target: &Target{}, |
|
|
|
|
@ -560,7 +561,7 @@ func TestScrapePoolRaces(t *testing.T) { |
|
|
|
|
newConfig := func() *config.ScrapeConfig { |
|
|
|
|
return &config.ScrapeConfig{ScrapeInterval: interval, ScrapeTimeout: timeout} |
|
|
|
|
} |
|
|
|
|
sp, _ := newScrapePool(newConfig(), &nopAppendable{}, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, _ := newScrapePool(newConfig(), &nopAppendable{}, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
tgts := []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Targets: []model.LabelSet{ |
|
|
|
|
@ -3279,7 +3280,7 @@ func TestReuseScrapeCache(t *testing.T) { |
|
|
|
|
ScrapeInterval: model.Duration(5 * time.Second), |
|
|
|
|
MetricsPath: "/metrics", |
|
|
|
|
} |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
t1 = &Target{ |
|
|
|
|
discoveredLabels: labels.FromStrings("labelNew", "nameNew", "labelNew1", "nameNew1", "labelNew2", "nameNew2"), |
|
|
|
|
} |
|
|
|
|
@ -3483,8 +3484,9 @@ func TestReuseCacheRace(t *testing.T) { |
|
|
|
|
ScrapeInterval: model.Duration(5 * time.Second), |
|
|
|
|
MetricsPath: "/metrics", |
|
|
|
|
} |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
t1 = &Target{ |
|
|
|
|
buffers = pool.New(1e3, 100e6, 3, func(sz int) interface{} { return make([]byte, 0, sz) }) |
|
|
|
|
sp, _ = newScrapePool(cfg, app, 0, nil, buffers, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
t1 = &Target{ |
|
|
|
|
discoveredLabels: labels.FromStrings("labelNew", "nameNew"), |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
@ -3614,7 +3616,7 @@ func TestScrapeReportLimit(t *testing.T) { |
|
|
|
|
})) |
|
|
|
|
defer ts.Close() |
|
|
|
|
|
|
|
|
|
sp, err := newScrapePool(cfg, s, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, err := newScrapePool(cfg, s, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
defer sp.stop() |
|
|
|
|
|
|
|
|
|
@ -3788,7 +3790,7 @@ func TestTargetScrapeIntervalAndTimeoutRelabel(t *testing.T) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
sp, _ := newScrapePool(config, &nopAppendable{}, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, _ := newScrapePool(config, &nopAppendable{}, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
tgts := []*targetgroup.Group{ |
|
|
|
|
{ |
|
|
|
|
Targets: []model.LabelSet{{model.AddressLabel: "127.0.0.1:9090"}}, |
|
|
|
|
@ -3879,7 +3881,7 @@ test_summary_count 199 |
|
|
|
|
})) |
|
|
|
|
defer ts.Close() |
|
|
|
|
|
|
|
|
|
sp, err := newScrapePool(config, simpleStorage, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, err := newScrapePool(config, simpleStorage, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
defer sp.stop() |
|
|
|
|
|
|
|
|
|
@ -4031,7 +4033,7 @@ func TestScrapeLoopCompression(t *testing.T) { |
|
|
|
|
EnableCompression: tc.enableCompression, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sp, err := newScrapePool(config, simpleStorage, 0, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
sp, err := newScrapePool(config, simpleStorage, 0, nil, nil, &Options{}, newTestScrapeMetrics(t)) |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
defer sp.stop() |
|
|
|
|
|
|
|
|
|
|