Skip to content

Commit

Permalink
♻️ Fix
Browse files Browse the repository at this point in the history
Signed-off-by: vankichi <kyukawa315@gmail.com>
  • Loading branch information
vankichi committed Mar 14, 2024
1 parent 5cd7ba0 commit d3c4a02
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 72 deletions.
124 changes: 63 additions & 61 deletions internal/observability/metrics/tools/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -125,33 +125,33 @@ func (om *operatorMetrics) View() ([]metrics.View, error) {
Aggregation: view.AggregationLastValue{},
},
),

Check warning on line 127 in internal/observability/metrics/tools/benchmark/benchmark.go

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L72-L127

Added lines #L72 - L127 were not covered by tests
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

Check warning on line 155 in internal/observability/metrics/tools/benchmark/benchmark.go

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L155

Added line #L155 was not covered by tests
}

Expand Down Expand Up @@ -206,30 +206,32 @@ func (om *operatorMetrics) Register(m metrics.Meter) error {
if err != nil {
return err

Check warning on line 207 in internal/observability/metrics/tools/benchmark/benchmark.go

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L201-L207

Added lines #L201 - L207 were not covered by tests
}
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 {

Check warning on line 236 in internal/observability/metrics/tools/benchmark/benchmark.go

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L235-L236

Added lines #L235 - L236 were not covered by tests
// scenario status
Expand Down Expand Up @@ -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

Check warning on line 284 in internal/observability/metrics/tools/benchmark/benchmark.go

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L284

Added line #L284 was not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 3 additions & 10 deletions pkg/tools/benchmark/operator/service/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Check warning on line 656 in pkg/tools/benchmark/operator/service/operator.go

View check run for this annotation

Codecov / codecov/patch

pkg/tools/benchmark/operator/service/operator.go#L654-L656

Added lines #L654 - L656 were not covered by tests
}
}
return m

Check warning on line 659 in pkg/tools/benchmark/operator/service/operator.go

View check run for this annotation

Codecov / codecov/patch

pkg/tools/benchmark/operator/service/operator.go#L659

Added line #L659 was not covered by tests
Expand All @@ -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

Check warning on line 671 in pkg/tools/benchmark/operator/service/operator.go

View check run for this annotation

Codecov / codecov/patch

pkg/tools/benchmark/operator/service/operator.go#L669-L671

Added lines #L669 - L671 were not covered by tests
}
}
return m

Check warning on line 674 in pkg/tools/benchmark/operator/service/operator.go

View check run for this annotation

Codecov / codecov/patch

pkg/tools/benchmark/operator/service/operator.go#L674

Added line #L674 was not covered by tests
Expand Down

0 comments on commit d3c4a02

Please sign in to comment.