Skip to content

Commit

Permalink
perf: RestPerf collectors should only run PollInstance for workloads
Browse files Browse the repository at this point in the history
Fixes: #2421
  • Loading branch information
cgrinds committed Oct 11, 2024
1 parent 391b6b7 commit dcc5d66
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
19 changes: 9 additions & 10 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,6 @@ func (r *RestPerf) PollData() (map[string]*matrix.Matrix, error) {
startTime time.Time
)

mat := r.Matrix[r.Object]
if len(mat.GetInstances()) == 0 {
return nil, errs.New(errs.ErrNoInstance, "no "+r.Object+" instances fetched in PollInstance")
}

timestamp := r.Matrix[r.Object].GetMetric(timestampMetricName)
if timestamp == nil {
return nil, errs.New(errs.ErrConfig, "missing timestamp metric")
Expand All @@ -703,7 +698,7 @@ func (r *RestPerf) PollData() (map[string]*matrix.Matrix, error) {
dataQuery := path.Join(r.Prop.Query, "rows")

var filter []string
// Sort filters so that the href is deterministic
// Sort metrics so that the href is deterministic
metrics := slices.Sorted(maps.Keys(r.Prop.Metrics))

filter = append(filter, "counters.name="+strings.Join(metrics, "|"))
Expand Down Expand Up @@ -870,10 +865,14 @@ func (r *RestPerf) pollData(startTime time.Time, perfRecords []rest.PerfRecord)

instance = curMat.GetInstance(instanceKey)
if instance == nil {
if !isWorkloadObject(r.Prop.Query) && !isWorkloadDetailObject(r.Prop.Query) {
r.Logger.Warn("Skip instanceKey, not found in cache", slog.String("instanceKey", instanceKey))
if isWorkloadObject(r.Prop.Query) || isWorkloadDetailObject(r.Prop.Query) {
return true
}
instance, err = curMat.NewInstance(instanceKey)
if err != nil {
r.Logger.Error("add instance", slogx.Err(err), slog.String("instanceKey", instanceKey))
return true
}
return true
}

// check for partial aggregation
Expand Down Expand Up @@ -1252,7 +1251,7 @@ func (r *RestPerf) pollData(startTime time.Time, perfRecords []rest.PerfRecord)
}
continue
}
// If we reach here then one of the earlier clauses should have executed `continue` statement
// If we reach here, then one of the earlier clauses should have executed `continue` statement
r.Logger.Error(
"Unknown property",
slog.String("key", key),
Expand Down
1 change: 1 addition & 0 deletions conf/restperf/9.12.0/workload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object: qos
client_timeout: 1m30s

schedule:
- instance: 10m
- data: 3m

counters:
Expand Down
1 change: 1 addition & 0 deletions conf/restperf/9.12.0/workload_detail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object: qos_detail
client_timeout: 1m30s

schedule:
- instance: 10m
- data: 3m

counters:
Expand Down
1 change: 1 addition & 0 deletions conf/restperf/9.12.0/workload_detail_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ object: qos_detail
client_timeout: 1m30s

schedule:
- instance: 10m
- data: 3m

counters:
Expand Down
1 change: 1 addition & 0 deletions conf/restperf/9.12.0/workload_volume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object: qos
client_timeout: 1m30s

schedule:
- instance: 10m
- data: 3m

counters:
Expand Down
1 change: 0 additions & 1 deletion conf/restperf/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ collector: RestPerf
# Order here matters!
schedule:
- counter: 24h
- instance: 10m
- data: 1m

objects:
Expand Down

0 comments on commit dcc5d66

Please sign in to comment.