Skip to content

Commit

Permalink
♻️ Update dashboard and rename
Browse files Browse the repository at this point in the history
Signed-off-by: vankichi <kyukawa315@gmail.com>
  • Loading branch information
vankichi committed Mar 13, 2024
1 parent cb0c47f commit 5cd7ba0
Show file tree
Hide file tree
Showing 4 changed files with 957 additions and 89 deletions.
137 changes: 113 additions & 24 deletions internal/observability/metrics/tools/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ 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"

runningJobCount = "benchmark_operator_running_job"
runningJobCountDescription = "Benchmark Operator running job count"

completeJobCount = "benchmark_operator_complete_job"
completeJobCountDescription = "Benchmark Operator complete job count"
)

const (
Expand Down Expand Up @@ -89,28 +98,82 @@ func (om *operatorMetrics) View() ([]metrics.View, error) {
Aggregation: view.AggregationLastValue{},
},
),
view.NewView(
view.Instrument{
Name: appliedBenchmarkJobCount,
Description: appliedBenchmarkJobCountDescription,
},
view.Stream{
Aggregation: view.AggregationLastValue{},
},
),
view.NewView(
view.Instrument{
Name: runningBenchmarkJobCount,
Description: runningBenchmarkJobCountDescription,
},
view.Stream{
Aggregation: view.AggregationLastValue{},
},
),
view.NewView(
view.Instrument{
Name: completeBenchmarkJobCount,
Description: completeBenchmarkJobCountDescription,
},
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#L72-L155

Added lines #L72 - L155 were not covered by tests
}

// TODO: implement here
func (om *operatorMetrics) Register(m metrics.Meter) error {
appliedScCount, err := m.Int64ObservableCounter(
appliedScenarioCount, err := m.Int64ObservableCounter(
appliedScenarioCount,
metrics.WithDescription(appliedScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
if err != nil {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L159-L166

Added lines #L159 - L166 were not covered by tests
}
runningScCount, err := m.Int64ObservableCounter(
runningScenarioCount, err := m.Int64ObservableCounter(
runningScenarioCount,
metrics.WithDescription(runningScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
if err != nil {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L168-L174

Added lines #L168 - L174 were not covered by tests
}
completeScCount, err := m.Int64ObservableCounter(
completeScenarioCount, err := m.Int64ObservableCounter(
completeScenarioCount,
metrics.WithDescription(completeScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
Expand All @@ -119,31 +182,54 @@ func (om *operatorMetrics) Register(m metrics.Meter) error {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L176-L182

Added lines #L176 - L182 were not covered by tests
}

appliedBjCount, err := m.Int64ObservableCounter(
appliedBenchJobCount, err := m.Int64ObservableCounter(
appliedBenchmarkJobCount,
metrics.WithDescription(appliedScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
if err != nil {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L185-L191

Added lines #L185 - L191 were not covered by tests
}
runningBjCount, err := m.Int64ObservableCounter(
runningBenchJobCount, err := m.Int64ObservableCounter(
runningBenchmarkJobCount,
metrics.WithDescription(runningScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
if err != nil {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L193-L199

Added lines #L193 - L199 were not covered by tests
}
completeBjCount, err := m.Int64ObservableCounter(
completeBenchJobCount, err := m.Int64ObservableCounter(
completeBenchmarkJobCount,
metrics.WithDescription(completeScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
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

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L209-L215

Added lines #L209 - L215 were not covered by tests
}
runningJobCount, err := m.Int64ObservableCounter(
runningJobCount,
metrics.WithDescription(runningJobCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
if err != nil {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L217-L223

Added lines #L217 - L223 were not covered by tests
}
completeJobCount, err := m.Int64ObservableCounter(
completeBenchmarkJobCount,
metrics.WithDescription(completeScenarioCountDescription),
metrics.WithUnit(metrics.Dimensionless),
)
if err != nil {
return err

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L225-L231

Added lines #L225 - L231 were not covered by tests
}

_, err = m.RegisterCallback(
func(_ context.Context, o api.Observer) error {

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L233-L234

Added lines #L233 - L234 were not covered by tests
// scenario status
Expand All @@ -152,43 +238,46 @@ func (om *operatorMetrics) Register(m metrics.Meter) error {
running: 0,
complete: 0,

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L236 - L239 were not covered by tests
}
for k, v := range om.op.LenBenchSC() {
for k, v := range om.op.GetScenarioStatus() {
sst[applied] += v
if k == v1.BenchmarkScenarioCompleted {
sst[complete] += v
} else {
sst[running] += v

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L241-L246

Added lines #L241 - L246 were not covered by tests
}
}
o.ObserveInt64(appliedScCount, sst[applied])
o.ObserveInt64(runningScCount, sst[running])
o.ObserveInt64(completeScCount, sst[complete])
o.ObserveInt64(appliedScenarioCount, sst[applied])
o.ObserveInt64(runningScenarioCount, sst[running])
o.ObserveInt64(completeScenarioCount, sst[complete])

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L249-L251

Added lines #L249 - L251 were not covered by tests

// benchmark job status
bst := map[string]int64{
applied: 0,
running: 0,
complete: 0,

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L254-L257

Added lines #L254 - L257 were not covered by tests
}
for k, v := range om.op.LenBenchBJ() {
sst[applied] += v
for k, v := range om.op.GetBenchmarkJobStatus() {
bst[applied] += v
if k == v1.BenchmarkJobCompleted {
sst[complete] += v
bst[complete] += v
} else {
sst[running] += v
bst[running] += v

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L259-L264

Added lines #L259 - L264 were not covered by tests
}
}
o.ObserveInt64(appliedBjCount, bst[applied])
o.ObserveInt64(runningBjCount, bst[running])
o.ObserveInt64(completeBjCount, bst[complete])
o.ObserveInt64(appliedBenchJobCount, bst[applied])
o.ObserveInt64(runningBenchJobCount, bst[running])
o.ObserveInt64(completeBenchJobCount, bst[complete])
return nil

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

View check run for this annotation

Codecov / codecov/patch

internal/observability/metrics/tools/benchmark/benchmark.go#L267-L270

Added lines #L267 - L270 were not covered by tests
},
appliedScCount,
runningScCount,
completeScCount,
appliedBjCount,
runningBjCount,
completeBjCount,
appliedScenarioCount,
runningScenarioCount,
completeScenarioCount,
appliedBenchJobCount,
runningBenchJobCount,
completeBenchJobCount,
appliedJobCount,
runningJobCount,
completeJobCount,
)
return nil

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L282 was not covered by tests
}
Loading

0 comments on commit 5cd7ba0

Please sign in to comment.