mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
lib/promscrape: avoid copying labels when -promscrape.dropOriginalLabels command-line flag is set
This should save some CPU
This regression has been introduced in 487f6380d0
when working on https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5389
This commit is contained in:
parent
9df42f000d
commit
61608b6303
1 changed files with 5 additions and 2 deletions
|
@ -1077,7 +1077,10 @@ func (swc *scrapeWorkConfig) getScrapeWork(target string, extraLabels, metaLabel
|
||||||
defer promutils.PutLabels(labels)
|
defer promutils.PutLabels(labels)
|
||||||
|
|
||||||
mergeLabels(labels, swc, target, extraLabels, metaLabels)
|
mergeLabels(labels, swc, target, extraLabels, metaLabels)
|
||||||
originalLabels := labels.Clone()
|
var originalLabels *promutils.Labels
|
||||||
|
if !*dropOriginalLabels {
|
||||||
|
originalLabels = labels.Clone()
|
||||||
|
}
|
||||||
labels.Labels = swc.relabelConfigs.Apply(labels.Labels, 0)
|
labels.Labels = swc.relabelConfigs.Apply(labels.Labels, 0)
|
||||||
// Remove labels starting from "__meta_" prefix according to https://www.robustperception.io/life-of-a-label/
|
// Remove labels starting from "__meta_" prefix according to https://www.robustperception.io/life-of-a-label/
|
||||||
labels.RemoveMetaLabels()
|
labels.RemoveMetaLabels()
|
||||||
|
@ -1212,7 +1215,7 @@ func (swc *scrapeWorkConfig) getScrapeWork(target string, extraLabels, metaLabel
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortOriginalLabelsIfNeeded(originalLabels *promutils.Labels) *promutils.Labels {
|
func sortOriginalLabelsIfNeeded(originalLabels *promutils.Labels) *promutils.Labels {
|
||||||
if *dropOriginalLabels {
|
if originalLabels == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
originalLabels.Sort()
|
originalLabels.Sort()
|
||||||
|
|
Loading…
Reference in a new issue