From 5ac0f18ca870f8238d0c208f4a46b35a34a2f57d Mon Sep 17 00:00:00 2001 From: lzfhust Date: Wed, 18 Jan 2023 14:57:56 +0800 Subject: [PATCH] using writeRequestCtxPool when delete kubernetes clusters from kubernetes_sd_configs (#3669) --- lib/promscrape/scrapework.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/promscrape/scrapework.go b/lib/promscrape/scrapework.go index 2370869db6..095138b0b3 100644 --- a/lib/promscrape/scrapework.go +++ b/lib/promscrape/scrapework.go @@ -773,7 +773,7 @@ func (sw *scrapeWork) sendStaleSeries(lastScrape, currScrape string, timestamp i if currScrape != "" { bodyString = parser.GetRowsDiff(lastScrape, currScrape) } - wc := &writeRequestCtx{} + wc := writeRequestCtxPool.Get(sw.prevLabelsLen) if bodyString != "" { wc.rows.UnmarshalWithErrLogger(bodyString, sw.logError) srcRows := wc.rows.Rows @@ -805,6 +805,8 @@ func (sw *scrapeWork) sendStaleSeries(lastScrape, currScrape string, timestamp i staleSamplesCreated.Add(len(samples)) } sw.pushData(sw.Config.AuthToken, &wc.writeRequest) + wc.reset() + writeRequestCtxPool.Put(wc) } var staleSamplesCreated = metrics.NewCounter(`vm_promscrape_stale_samples_created_total`)