Only relabelling should apply for scrape_samples_scraped_post_relabelling. (#7342)

More consistent variable names.

Fixes #7298

Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
This commit is contained in:
Brian Brazil 2020-06-04 16:00:37 +01:00 committed by GitHub
parent c729df3d0f
commit f9d21f10ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View file

@ -1140,7 +1140,7 @@ loop:
if ok { if ok {
err = app.AddFast(ce.ref, t, v) err = app.AddFast(ce.ref, t, v)
sampleAdded, err = sl.checkAddError(ce, met, tp, err, &sampleLimitErr, &appErrs) _, err = sl.checkAddError(ce, met, tp, err, &sampleLimitErr, &appErrs)
// In theory this should never happen. // In theory this should never happen.
if err == storage.ErrNotFound { if err == storage.ErrNotFound {
ok = false ok = false
@ -1187,10 +1187,10 @@ loop:
} }
} }
// Increment added even if there's a sampleLimitErr so we correctly report the number of samples scraped. // Increment added even if there's an error so we correctly report the
if sampleAdded || sampleLimitErr != nil { // number of samples remaining after relabelling.
added++ added++
}
} }
if sampleLimitErr != nil { if sampleLimitErr != nil {
if err == nil { if err == nil {
@ -1275,7 +1275,7 @@ const (
scrapeSeriesAddedMetricName = "scrape_series_added" + "\xff" scrapeSeriesAddedMetricName = "scrape_series_added" + "\xff"
) )
func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scraped, appended, seriesAdded int, scrapeErr error) (err error) { func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scraped, added, seriesAdded int, scrapeErr error) (err error) {
sl.scraper.Report(start, duration, scrapeErr) sl.scraper.Report(start, duration, scrapeErr)
ts := timestamp.FromTime(start) ts := timestamp.FromTime(start)
@ -1302,7 +1302,7 @@ func (sl *scrapeLoop) report(start time.Time, duration time.Duration, scraped, a
if err = sl.addReportSample(app, scrapeSamplesMetricName, ts, float64(scraped)); err != nil { if err = sl.addReportSample(app, scrapeSamplesMetricName, ts, float64(scraped)); err != nil {
return return
} }
if err = sl.addReportSample(app, samplesPostRelabelMetricName, ts, float64(appended)); err != nil { if err = sl.addReportSample(app, samplesPostRelabelMetricName, ts, float64(added)); err != nil {
return return
} }
if err = sl.addReportSample(app, scrapeSeriesAddedMetricName, ts, float64(seriesAdded)); err != nil { if err = sl.addReportSample(app, scrapeSeriesAddedMetricName, ts, float64(seriesAdded)); err != nil {

View file

@ -1340,7 +1340,7 @@ func TestScrapeLoopAppendGracefullyIfAmendOrOutOfOrderOrOutOfBounds(t *testing.T
} }
testutil.Equals(t, want, app.result, "Appended samples not as expected") testutil.Equals(t, want, app.result, "Appended samples not as expected")
testutil.Equals(t, 4, total) testutil.Equals(t, 4, total)
testutil.Equals(t, 1, added) testutil.Equals(t, 4, added)
testutil.Equals(t, 1, seriesAdded) testutil.Equals(t, 1, seriesAdded)
} }
@ -1365,7 +1365,7 @@ func TestScrapeLoopOutOfBoundsTimeError(t *testing.T) {
now := time.Now().Add(20 * time.Minute) now := time.Now().Add(20 * time.Minute)
total, added, seriesAdded, err := sl.append([]byte("normal 1\n"), "", now) total, added, seriesAdded, err := sl.append([]byte("normal 1\n"), "", now)
testutil.Equals(t, 1, total) testutil.Equals(t, 1, total)
testutil.Equals(t, 0, added) testutil.Equals(t, 1, added)
testutil.Equals(t, 0, seriesAdded) testutil.Equals(t, 0, seriesAdded)
testutil.Ok(t, err) testutil.Ok(t, err)