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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"strconv"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/go-kit/kit/log"
|
"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
|
// Export order: user nice sys intr idle
|
||||||
cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
|
cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
|
||||||
for i, value := range cpuTimes {
|
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])
|
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,
|
1,
|
||||||
cpu.PhysicalID,
|
cpu.PhysicalID,
|
||||||
cpu.CoreID,
|
cpu.CoreID,
|
||||||
fmt.Sprintf("%d", cpu.Processor),
|
strconv.Itoa(int(cpu.Processor)),
|
||||||
cpu.VendorID,
|
cpu.VendorID,
|
||||||
cpu.CPUFamily,
|
cpu.CPUFamily,
|
||||||
cpu.Model,
|
cpu.Model,
|
||||||
|
@ -202,7 +202,7 @@ func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for cpuID, cpuStat := range stats.CPU {
|
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.User, cpuNum, "user")
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Nice, cpuNum, "nice")
|
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Nice, cpuNum, "nice")
|
||||||
ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.System, cpuNum, "system")
|
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(
|
ch <- c.desc.mustNewConstMetric(
|
||||||
value,
|
value,
|
||||||
strconv.Itoa(cpuNo),
|
strconv.Itoa(cpuNo),
|
||||||
fmt.Sprintf("%d", interrupt.vector),
|
strconv.Itoa(interrupt.vector),
|
||||||
dev,
|
dev,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
package collector
|
package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
"github.com/hodgesds/perf-utils"
|
"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 {
|
func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
|
||||||
for cpu, profiler := range c.perfHwProfilers {
|
for cpu, profiler := range c.perfHwProfilers {
|
||||||
cpuStr := fmt.Sprintf("%d", cpu)
|
cpuStr := strconv.Itoa(cpu)
|
||||||
hwProfile, err := profiler.Profile()
|
hwProfile, err := profiler.Profile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -405,7 +405,7 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
|
||||||
|
|
||||||
func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
|
func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
|
||||||
for cpu, profiler := range c.perfSwProfilers {
|
for cpu, profiler := range c.perfSwProfilers {
|
||||||
cpuStr := fmt.Sprintf("%d", cpu)
|
cpuStr := strconv.Itoa(cpu)
|
||||||
swProfile, err := profiler.Profile()
|
swProfile, err := profiler.Profile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -460,7 +460,7 @@ func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
|
||||||
|
|
||||||
func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
|
func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
|
||||||
for cpu, profiler := range c.perfCacheProfilers {
|
for cpu, profiler := range c.perfCacheProfilers {
|
||||||
cpuStr := fmt.Sprintf("%d", cpu)
|
cpuStr := strconv.Itoa(cpu)
|
||||||
cacheProfile, err := profiler.Profile()
|
cacheProfile, err := profiler.Profile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue