scrape: Fix label_limits cache usage (#10370)

Fixes #10344

Signed-off-by: Jayapriya Pai <janantha@redhat.com>
This commit is contained in:
Jayapriya Pai 2022-03-03 23:07:53 +05:30 committed by GitHub
parent da23c4649a
commit edfe657b54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 3 deletions

View file

@ -1777,9 +1777,6 @@ func zeroConfig(c *config.ScrapeConfig) *config.ScrapeConfig {
z.ScrapeInterval = 0
z.ScrapeTimeout = 0
z.SampleLimit = 0
z.LabelLimit = 0
z.LabelNameLengthLimit = 0
z.LabelValueLengthLimit = 0
z.HTTPClientConfig = config_util.HTTPClientConfig{}
return &z
}

View file

@ -2519,6 +2519,14 @@ func TestReuseScrapeCache(t *testing.T) {
Name: "labelNew",
Value: "nameNew",
},
labels.Label{
Name: "labelNew1",
Value: "nameNew1",
},
labels.Label{
Name: "labelNew2",
Value: "nameNew2",
},
},
}
proxyURL, _ = url.Parse("http://localhost:2128")
@ -2595,6 +2603,49 @@ func TestReuseScrapeCache(t *testing.T) {
MetricsPath: "/metrics2",
},
},
{
keep: false,
newConfig: &config.ScrapeConfig{
JobName: "Prometheus",
ScrapeInterval: model.Duration(5 * time.Second),
ScrapeTimeout: model.Duration(15 * time.Second),
MetricsPath: "/metrics",
LabelLimit: 1,
},
},
{
keep: false,
newConfig: &config.ScrapeConfig{
JobName: "Prometheus",
ScrapeInterval: model.Duration(5 * time.Second),
ScrapeTimeout: model.Duration(15 * time.Second),
MetricsPath: "/metrics",
LabelLimit: 15,
},
},
{
keep: false,
newConfig: &config.ScrapeConfig{
JobName: "Prometheus",
ScrapeInterval: model.Duration(5 * time.Second),
ScrapeTimeout: model.Duration(15 * time.Second),
MetricsPath: "/metrics",
LabelLimit: 15,
LabelNameLengthLimit: 5,
},
},
{
keep: false,
newConfig: &config.ScrapeConfig{
JobName: "Prometheus",
ScrapeInterval: model.Duration(5 * time.Second),
ScrapeTimeout: model.Duration(15 * time.Second),
MetricsPath: "/metrics",
LabelLimit: 15,
LabelNameLengthLimit: 5,
LabelValueLengthLimit: 7,
},
},
}
cacheAddr := func(sp *scrapePool) map[uint64]string {