Use strconv.Itoa() instead of fmt.Sprintf() (#1566)
Signed-off-by: Julian Kornberger <jk+github@digineo.de>pull/1563/head^2
parent
6ad94ae4bc
commit
cfcaeee145
|
@ -17,7 +17,7 @@ package collector
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
|
@ -131,7 +131,7 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
// Export order: user nice sys intr idle
|
||||
cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
|
||||
for i, value := range cpuTimes {
|
||||
cpux := fmt.Sprintf("%d", i/fieldsCount)
|
||||
cpux := strconv.Itoa(i / fieldsCount)
|
||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, value, cpux, cpuFields[i%fieldsCount])
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error {
|
|||
1,
|
||||
cpu.PhysicalID,
|
||||
cpu.CoreID,
|
||||
fmt.Sprintf("%d", cpu.Processor),
|
||||
strconv.Itoa(int(cpu.Processor)),
|
||||
cpu.VendorID,
|
||||
cpu.CPUFamily,
|
||||
cpu.Model,
|
||||
|
@ -202,7 +202,7 @@ func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error {
|
|||
}
|
||||
|
||||
for cpuID, cpuStat := range stats.CPU {
|
||||
cpuNum := fmt.Sprintf("%d", cpuID)
|
||||
cpuNum := strconv.Itoa(cpuID)
|
||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.User, cpuNum, "user")
|
||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Nice, cpuNum, "nice")
|
||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.System, cpuNum, "system")
|
||||
|
|
|
@ -108,7 +108,7 @@ func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
ch <- c.desc.mustNewConstMetric(
|
||||
value,
|
||||
strconv.Itoa(cpuNo),
|
||||
fmt.Sprintf("%d", interrupt.vector),
|
||||
strconv.Itoa(interrupt.vector),
|
||||
dev,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
package collector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strconv"
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/hodgesds/perf-utils"
|
||||
|
@ -334,7 +334,7 @@ func (c *perfCollector) Update(ch chan<- prometheus.Metric) error {
|
|||
|
||||
func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
|
||||
for cpu, profiler := range c.perfHwProfilers {
|
||||
cpuStr := fmt.Sprintf("%d", cpu)
|
||||
cpuStr := strconv.Itoa(cpu)
|
||||
hwProfile, err := profiler.Profile()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -405,7 +405,7 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
|
|||
|
||||
func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
|
||||
for cpu, profiler := range c.perfSwProfilers {
|
||||
cpuStr := fmt.Sprintf("%d", cpu)
|
||||
cpuStr := strconv.Itoa(cpu)
|
||||
swProfile, err := profiler.Profile()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -460,7 +460,7 @@ func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
|
|||
|
||||
func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
|
||||
for cpu, profiler := range c.perfCacheProfilers {
|
||||
cpuStr := fmt.Sprintf("%d", cpu)
|
||||
cpuStr := strconv.Itoa(cpu)
|
||||
cacheProfile, err := profiler.Profile()
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue