lib/promrelabel: remove unneded optimizations for labeldrop and labelkeep actions

These optimizations may slow down code execution by matching the same label against regexp two times instead of a single time
This commit is contained in:
Aliaksandr Valialkin 2021-03-02 17:54:31 +02:00
parent f9c1fe3852
commit 62d7e07ff7

View file

@ -225,17 +225,6 @@ func (prc *parsedRelabelConfig) apply(labels []prompbmarshal.Label, labelsOffset
}
return labels
case "labeldrop":
keepSrc := true
for i := range src {
label := &src[i]
if prc.matchString(label.Name) {
keepSrc = false
break
}
}
if keepSrc {
return labels
}
dst := labels[:labelsOffset]
for i := range src {
label := &src[i]
@ -245,17 +234,6 @@ func (prc *parsedRelabelConfig) apply(labels []prompbmarshal.Label, labelsOffset
}
return dst
case "labelkeep":
keepSrc := true
for i := range src {
label := &src[i]
if !prc.matchString(label.Name) {
keepSrc = false
break
}
}
if keepSrc {
return labels
}
dst := labels[:labelsOffset]
for i := range src {
label := &src[i]