From 62d7e07ff75c191a098b261f9ffeca5484f9e942 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 2 Mar 2021 17:54:31 +0200 Subject: [PATCH] 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 --- lib/promrelabel/relabel.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lib/promrelabel/relabel.go b/lib/promrelabel/relabel.go index 477cf2bea..1ee0e9868 100644 --- a/lib/promrelabel/relabel.go +++ b/lib/promrelabel/relabel.go @@ -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]