Skip to content

Commit

Permalink
add smaller interfaces local to packages using them
Browse files Browse the repository at this point in the history
  • Loading branch information
moh-osman3 committed Nov 8, 2022
1 parent 87632ac commit 9e015db
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 19 deletions.
4 changes: 0 additions & 4 deletions cmd/otel-allocator/prehook/prehook.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ var (
Name: "opentelemetry_allocator_targets_kept",
Help: "Number of targets kept after filtering.",
}, []string{"job_name"})
TargetsDropped = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "opentelemetry_allocator_targets_dropped",
Help: "Number of targets dropped after filtering.",
}, []string{"job_name"})
)

type Hook interface {
Expand Down
13 changes: 0 additions & 13 deletions cmd/otel-allocator/prehook/relabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,12 @@ func convertLabelToPromLabelSet(lbls model.LabelSet) []labels.Label {

func (tf *RelabelConfigTargetFilter) Apply(targets map[string]*target.Item) map[string]*target.Item {
numTargets := len(targets)
var droppedTargetsPerJob, targetsPerJob map[string]float64

// need to wait until relabelCfg is set
if len(tf.relabelCfg) == 0 {
return targets
}

droppedTargetsPerJob = make(map[string]float64)
targetsPerJob = GetTargetsPerJob(targets)

// Note: jobNameKey != tItem.JobName (jobNameKey is hashed)
for jobNameKey, tItem := range targets {
keepTarget := true
Expand All @@ -74,16 +70,7 @@ func (tf *RelabelConfigTargetFilter) Apply(targets map[string]*target.Item) map[

if !keepTarget {
delete(targets, jobNameKey)
droppedTargetsPerJob[tItem.JobName] += 1
}

}

// add metrics for number of targets kept and dropped per job.
for jName, numTargets := range targetsPerJob {
numDropped := droppedTargetsPerJob[jName]
TargetsDropped.WithLabelValues(jName).Set(numDropped)
TargetsKept.WithLabelValues(jName).Set(numTargets-numDropped)
}

tf.log.V(2).Info("Filtering complete", "seen", numTargets, "kept", len(targets))
Expand Down
2 changes: 0 additions & 2 deletions pkg/collector/reconcile/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ config:
- targets:
- 0.0.0.0:8888
- 0.0.0.0:9999
filter_strategy: no-op
label_selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: default.test
Expand Down Expand Up @@ -327,7 +326,6 @@ func TestExpectedConfigMap(t *testing.T) {
}
taConfig["config"] = parmConfig
taConfig["allocation_strategy"] = "least-weighted"
taConfig["filter_strategy"] = "no-op"
taConfigYAML, _ := yaml.Marshal(taConfig)

assert.Equal(t, string(taConfigYAML), actual.Data["targetallocator.yaml"])
Expand Down

0 comments on commit 9e015db

Please sign in to comment.