mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01: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
4954eee187
commit
b564729d75
@ -1077,7 +1077,10 @@ func (swc *scrapeWorkConfig) getScrapeWork(target string, extraLabels, metaLabel
|
||||
defer promutils.PutLabels(labels)
|
||||
|
||||
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)
|
||||
// Remove labels starting from "__meta_" prefix according to https://www.robustperception.io/life-of-a-label/
|
||||
labels.RemoveMetaLabels()
|
||||
@ -1212,7 +1215,7 @@ func (swc *scrapeWorkConfig) getScrapeWork(target string, extraLabels, metaLabel
|
||||
}
|
||||
|
||||
func sortOriginalLabelsIfNeeded(originalLabels *promutils.Labels) *promutils.Labels {
|
||||
if *dropOriginalLabels {
|
||||
if originalLabels == nil {
|
||||
return nil
|
||||
}
|
||||
originalLabels.Sort()
|
||||
|
Loading…
Reference in New Issue
Block a user