Skip to content

Commit

Permalink
remove unrequired type cast an math.Round when inserting exec metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Jan 31, 2024
1 parent a3d0de5 commit 50acd8a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions go/exec/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package metrics

import (
"fmt"
"math"
"strings"

"github.com/vitessio/arewefastyet/go/storage"
Expand Down Expand Up @@ -123,19 +122,19 @@ func NewExecMetrics() ExecutionMetrics {
func InsertExecutionMetrics(client storage.SQLClient, execUUID string, execMetrics ExecutionMetrics) error {
query := "INSERT INTO metrics(exec_uuid, `name`, `value`) VALUES (?, ?, ?), (?, ?, ?)"
args := []interface{}{
execUUID, "TotalComponentsCPUTime", math.Round(float64(int(execMetrics.TotalComponentsCPUTime*100))) / 100,
execUUID, "TotalComponentsMemStatsAllocBytes", math.Round(float64(int(execMetrics.TotalComponentsMemStatsAllocBytes*100))) / 100,
execUUID, "TotalComponentsCPUTime", execMetrics.TotalComponentsCPUTime,
execUUID, "TotalComponentsMemStatsAllocBytes", execMetrics.TotalComponentsMemStatsAllocBytes,
}
for k, v := range execMetrics.ComponentsCPUTime {
query += ", (?,?,?)"
args = append(args, []interface{}{
execUUID, "ComponentsCPUTime." + k, math.Round(float64(int(v*100))) / 100,
execUUID, "ComponentsCPUTime." + k, v,
}...)
}
for k, v := range execMetrics.ComponentsMemStatsAllocBytes {
query += ", (?,?,?)"
args = append(args, []interface{}{
execUUID, "ComponentsMemStatsAllocBytes." + k, math.Round(float64(int(v*100))) / 100,
execUUID, "ComponentsMemStatsAllocBytes." + k, v,
}...)
}
_, err := client.Insert(query, args...)
Expand Down

0 comments on commit 50acd8a

Please sign in to comment.