mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Merge 1a1e254244
into 61aa82865d
This commit is contained in:
commit
ede5b574be
|
@ -1034,9 +1034,8 @@ func (c *scrapeCache) iterDone(flushCache bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.metaMtx.Unlock()
|
c.metaMtx.Unlock()
|
||||||
|
|
||||||
c.iter++
|
|
||||||
}
|
}
|
||||||
|
c.iter++
|
||||||
|
|
||||||
// Swap current and previous series.
|
// Swap current and previous series.
|
||||||
c.seriesPrev, c.seriesCur = c.seriesCur, c.seriesPrev
|
c.seriesPrev, c.seriesCur = c.seriesCur, c.seriesPrev
|
||||||
|
|
|
@ -5153,3 +5153,38 @@ func TestScrapePoolScrapeAfterReload(t *testing.T) {
|
||||||
|
|
||||||
<-time.After(1 * time.Second)
|
<-time.After(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression test against https://github.com/prometheus/prometheus/issues/16160.
|
||||||
|
func TestScrapeAppendWithParseError(t *testing.T) {
|
||||||
|
const (
|
||||||
|
scrape1 = `metric_a 1
|
||||||
|
`
|
||||||
|
scrape2 = `metric_a 11
|
||||||
|
# EOF`
|
||||||
|
)
|
||||||
|
|
||||||
|
sl := newBasicScrapeLoop(t, context.Background(), nil, nil, 0)
|
||||||
|
sl.cache = newScrapeCache(sl.metrics)
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
capp := &collectResultAppender{next: nopAppender{}}
|
||||||
|
_, _, _, err := sl.append(capp, []byte(scrape1), "application/openmetrics-text", now)
|
||||||
|
require.Error(t, err)
|
||||||
|
_, _, _, err = sl.append(capp, nil, "application/openmetrics-text", now)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Empty(t, capp.resultFloats)
|
||||||
|
|
||||||
|
capp = &collectResultAppender{next: nopAppender{}}
|
||||||
|
_, _, _, err = sl.append(capp, []byte(scrape2), "application/openmetrics-text", now.Add(15*time.Second))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NoError(t, capp.Commit())
|
||||||
|
|
||||||
|
want := []floatSample{
|
||||||
|
{
|
||||||
|
metric: labels.FromStrings(model.MetricNameLabel, "metric_a"),
|
||||||
|
t: timestamp.FromTime(now.Add(15 * time.Second)),
|
||||||
|
f: 11,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
requireEqual(t, want, capp.resultFloats, "Appended samples not as expected:\n%s", capp)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue