Skip to content

Commit

Permalink
Refactor the relabel loop
Browse files Browse the repository at this point in the history
  • Loading branch information
swiatekm committed Nov 6, 2024
1 parent 11ae3ea commit 221cc8e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cmd/otel-allocator/prehook/relabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@ func (tf *RelabelConfigTargetFilter) Apply(targets map[string]*target.Item) map[

// Note: jobNameKey != tItem.JobName (jobNameKey is hashed)
for jobNameKey, tItem := range targets {
keepTarget := true
var keepTarget bool
lset := tItem.Labels
for _, cfg := range tf.relabelCfg[tItem.JobName] {
lset, keepTarget = relabel.Process(lset, cfg)
if !keepTarget {
delete(targets, jobNameKey)
break // inner loop
}
}

if !keepTarget {
delete(targets, jobNameKey)
}
}

tf.log.V(2).Info("Filtering complete", "seen", numTargets, "kept", len(targets))
Expand Down

0 comments on commit 221cc8e

Please sign in to comment.