Skip to content

Commit de89f7c

Browse files
committed
Drop half of the targets in relabel benchmark
1 parent 05a55b6 commit de89f7c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cmd/otel-allocator/benchmark_test.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"context"
1919
"fmt"
2020
"os"
21+
"strconv"
22+
"strings"
2123
"testing"
2224

2325
gokitlog "github.com/go-kit/log"
@@ -27,6 +29,7 @@ import (
2729
"github.com/prometheus/prometheus/discovery"
2830
"github.com/prometheus/prometheus/discovery/targetgroup"
2931
"github.com/prometheus/prometheus/model/relabel"
32+
"github.com/stretchr/testify/require"
3033
ctrl "sigs.k8s.io/controller-runtime"
3134
"sigs.k8s.io/controller-runtime/pkg/log"
3235

@@ -66,10 +69,21 @@ func BenchmarkProcessTargetsWithRelabelConfig(b *testing.B) {
6669
tsets := prepareBenchmarkData(numTargets, targetsPerGroup, groupsPerJob)
6770
prehookConfig := make(map[string][]*relabel.Config, len(tsets))
6871
for jobName := range tsets {
72+
// keep all targets in half the jobs, drop the rest
73+
jobNrStr := strings.Split(jobName, "-")[1]
74+
jobNr, err := strconv.Atoi(jobNrStr)
75+
require.NoError(b, err)
76+
var action relabel.Action
77+
if jobNr%2 == 0 {
78+
action = "keep"
79+
} else {
80+
action = "drop"
81+
}
6982
prehookConfig[jobName] = []*relabel.Config{
7083
{
71-
Action: "keep",
72-
Regex: relabel.MustNewRegexp(".*"),
84+
Action: action,
85+
Regex: relabel.MustNewRegexp(".*"),
86+
SourceLabels: model.LabelNames{"__address__"},
7387
},
7488
}
7589
}

0 commit comments

Comments
 (0)