Skip to content

Commit

Permalink
feat: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Oct 7, 2024
1 parent be9bebf commit 0d5f049
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions cmd/collectors/keyperf/keyperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ func (kp *KeyPerf) loadParamInt(name string, defaultValue int) int {
func (kp *KeyPerf) buildCounters() {
staticCounterDef, err := loadStaticCounterDefinitions(kp.Prop.Object, "cmd/collectors/keyperf/static_counter_definitions.yaml", kp.Logger)
if err != nil {
// It's acceptable to continue even if there are errors, as the remaining counters will still be processed.
// Any counters that require counter metadata will be skipped.
kp.Logger.Error("Failed to load static counter definitions", slog.Any("error", err))
}

Expand Down Expand Up @@ -202,7 +204,7 @@ func (kp *KeyPerf) buildCounters() {
}
}
} else {
slog.Warn("Skipping metric due to unknown metricType", "name", k, "metricType", v.MetricType)
slog.Warn("Skipping metric due to unknown metricType", slog.String("name", k), slog.String("metricType", v.MetricType))
}
}

Expand Down Expand Up @@ -410,7 +412,7 @@ func (kp *KeyPerf) pollData(
slog.String("denominator", counter.denominator),
slog.Int("instIndex", instIndex),
)
skips = curMat.Record(key, false)
skips = curMat.Skip(key)
totalSkips += skips
continue
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,12 @@ func (m *Matrix) MultiplyByScalar(metricKey string, s uint) (int, error) {
return skips, nil
}

func (m *Matrix) Record(metricKey string, record bool) int {
func (m *Matrix) Skip(metricKey string) int {
var skips int
metric := m.GetMetric(metricKey)
for i := range len(metric.values) {
metric.record[i] = record
if !record {
if metric != nil {
for i := range len(metric.values) {
metric.record[i] = false
skips++
}
}
Expand Down

0 comments on commit 0d5f049

Please sign in to comment.