diff --git a/internal/observability/metrics/tools/benchmark/benchmark.go b/internal/observability/metrics/tools/benchmark/benchmark.go index 6c45c71f2c..f53c95a06a 100644 --- a/internal/observability/metrics/tools/benchmark/benchmark.go +++ b/internal/observability/metrics/tools/benchmark/benchmark.go @@ -42,14 +42,14 @@ const ( completeBenchmarkJobCount = "benchmark_operator_complete_benchmark_job" completeBenchmarkJobCountDescription = "Benchmark Operator complete benchmark job count" - appliedJobCount = "benchmark_operator_applied_job" - appliedJobCountDescription = "Benchmark Operator applied job count" + // appliedJobCount = "benchmark_operator_applied_job" + // appliedJobCountDescription = "Benchmark Operator applied job count" - runningJobCount = "benchmark_operator_running_job" - runningJobCountDescription = "Benchmark Operator running job count" + // runningJobCount = "benchmark_operator_running_job" + // runningJobCountDescription = "Benchmark Operator running job count" - completeJobCount = "benchmark_operator_complete_job" - completeJobCountDescription = "Benchmark Operator complete job count" + // completeJobCount = "benchmark_operator_complete_job" + // completeJobCountDescription = "Benchmark Operator complete job count" ) const ( @@ -125,33 +125,33 @@ func (om *operatorMetrics) View() ([]metrics.View, error) { Aggregation: view.AggregationLastValue{}, }, ), - view.NewView( - view.Instrument{ - Name: appliedJobCount, - Description: appliedJobCountDescription, - }, - view.Stream{ - Aggregation: view.AggregationLastValue{}, - }, - ), - view.NewView( - view.Instrument{ - Name: runningJobCount, - Description: runningJobCountDescription, - }, - view.Stream{ - Aggregation: view.AggregationLastValue{}, - }, - ), - view.NewView( - view.Instrument{ - Name: completeJobCount, - Description: completeJobCountDescription, - }, - view.Stream{ - Aggregation: view.AggregationLastValue{}, - }, - ), + // view.NewView( + // view.Instrument{ + // Name: appliedJobCount, + // Description: appliedJobCountDescription, + // }, + // view.Stream{ + // Aggregation: view.AggregationLastValue{}, + // }, + // ), + // view.NewView( + // view.Instrument{ + // Name: runningJobCount, + // Description: runningJobCountDescription, + // }, + // view.Stream{ + // Aggregation: view.AggregationLastValue{}, + // }, + // ), + // view.NewView( + // view.Instrument{ + // Name: completeJobCount, + // Description: completeJobCountDescription, + // }, + // view.Stream{ + // Aggregation: view.AggregationLastValue{}, + // }, + // ), }, nil } @@ -206,30 +206,32 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { if err != nil { return err } - appliedJobCount, err := m.Int64ObservableCounter( - appliedJobCount, - metrics.WithDescription(appliedJobCountDescription), - metrics.WithUnit(metrics.Dimensionless), - ) - if err != nil { - return err - } - runningJobCount, err := m.Int64ObservableCounter( - runningJobCount, - metrics.WithDescription(runningJobCountDescription), - metrics.WithUnit(metrics.Dimensionless), - ) - if err != nil { - return err - } - completeJobCount, err := m.Int64ObservableCounter( - completeBenchmarkJobCount, - metrics.WithDescription(completeScenarioCountDescription), - metrics.WithUnit(metrics.Dimensionless), - ) - if err != nil { - return err - } + + // appliedJobCount, err := m.Int64ObservableCounter( + // appliedJobCount, + // metrics.WithDescription(appliedJobCountDescription), + // metrics.WithUnit(metrics.Dimensionless), + // ) + // if err != nil { + // return err + // } + // runningJobCount, err := m.Int64ObservableCounter( + // runningJobCount, + // metrics.WithDescription(runningJobCountDescription), + // metrics.WithUnit(metrics.Dimensionless), + // ) + // if err != nil { + // return err + // } + // completeJobCount, err := m.Int64ObservableCounter( + // completeBenchmarkJobCount, + // metrics.WithDescription(completeScenarioCountDescription), + // metrics.WithUnit(metrics.Dimensionless), + // ) + // if err != nil { + // return err + // } + _, err = m.RegisterCallback( func(_ context.Context, o api.Observer) error { // scenario status @@ -275,9 +277,9 @@ func (om *operatorMetrics) Register(m metrics.Meter) error { appliedBenchJobCount, runningBenchJobCount, completeBenchJobCount, - appliedJobCount, - runningJobCount, - completeJobCount, + // appliedJobCount, + // runningJobCount, + // completeJobCount, ) - return nil + return err } diff --git a/internal/observability/metrics/tools/benchmark/benchmark_test.go b/internal/observability/metrics/tools/benchmark/benchmark_test.go index ba64190d5a..b444083232 100644 --- a/internal/observability/metrics/tools/benchmark/benchmark_test.go +++ b/internal/observability/metrics/tools/benchmark/benchmark_test.go @@ -17,7 +17,7 @@ import ( "reflect" "testing" - "github.com/pkg/errors" + "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/observability/metrics" "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/tools/benchmark/operator/service" diff --git a/pkg/tools/benchmark/operator/service/operator.go b/pkg/tools/benchmark/operator/service/operator.go index 89beca20b9..fbd4a05ab8 100644 --- a/pkg/tools/benchmark/operator/service/operator.go +++ b/pkg/tools/benchmark/operator/service/operator.go @@ -450,6 +450,7 @@ func (o *operator) createBenchmarkJob(ctx context.Context, scenario v1.ValdBench } // set status bj.Status = v1.BenchmarkJobNotReady + // TODO: set metrics // create benchmark job resource c := o.ctrl.GetManager().GetClient() if err := c.Create(ctx, bj); err != nil { @@ -652,11 +653,7 @@ func (o *operator) GetScenarioStatus() map[v1.ValdBenchmarkScenarioStatus]int64 } if sc := o.getAtomicScenario(); sc != nil { for _, s := range sc { - if _, ok := m[s.Crd.Status]; ok { - m[s.Crd.Status] += 1 - } else { - m[s.Crd.Status] = 1 - } + m[s.Crd.Status] += 1 } } return m @@ -671,11 +668,7 @@ func (o *operator) GetBenchmarkJobStatus() map[v1.BenchmarkJobStatus]int64 { } if bjs := o.getAtomicBenchJob(); bjs != nil { for _, bj := range bjs { - if _, ok := m[bj.Status]; ok { - m[bj.Status] += 1 - } else { - m[bj.Status] = 1 - } + m[bj.Status] += 1 } } return m