aboutsummaryrefslogtreecommitdiff
path: root/collector
diff options
context:
space:
mode:
authorJulian Kornberger <jk+github@digineo.de>2020-02-19 14:34:05 +0100
committerGitHub <noreply@github.com>2020-02-19 14:34:05 +0100
commitcfcaeee1458f1e8dd66e155bff98716ce8d8ce76 (patch)
treed66a73bfbe7e35563f9d82b8dbccf48ad7d2f96c /collector
parent6ad94ae4bc5527037ce0e6b8462f58cb3b8ccef3 (diff)
downloadprometheus_node_collector-cfcaeee1458f1e8dd66e155bff98716ce8d8ce76.tar.bz2
prometheus_node_collector-cfcaeee1458f1e8dd66e155bff98716ce8d8ce76.tar.xz
prometheus_node_collector-cfcaeee1458f1e8dd66e155bff98716ce8d8ce76.zip
Use strconv.Itoa() instead of fmt.Sprintf() (#1566)
Signed-off-by: Julian Kornberger <jk+github@digineo.de>
Diffstat (limited to 'collector')
-rw-r--r--collector/cpu_dragonfly.go4
-rw-r--r--collector/cpu_linux.go4
-rw-r--r--collector/interrupts_openbsd.go2
-rw-r--r--collector/perf_linux.go8
4 files changed, 9 insertions, 9 deletions
diff --git a/collector/cpu_dragonfly.go b/collector/cpu_dragonfly.go
index beef390..4ccb729 100644
--- a/collector/cpu_dragonfly.go
+++ b/collector/cpu_dragonfly.go
@@ -17,7 +17,7 @@ package collector
17 17
18import ( 18import (
19 "errors" 19 "errors"
20 "fmt" 20 "strconv"
21 "unsafe" 21 "unsafe"
22 22
23 "github.com/go-kit/kit/log" 23 "github.com/go-kit/kit/log"
@@ -131,7 +131,7 @@ func (c *statCollector) Update(ch chan<- prometheus.Metric) error {
131 // Export order: user nice sys intr idle 131 // Export order: user nice sys intr idle
132 cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"} 132 cpuFields := []string{"user", "nice", "sys", "interrupt", "idle"}
133 for i, value := range cpuTimes { 133 for i, value := range cpuTimes {
134 cpux := fmt.Sprintf("%d", i/fieldsCount) 134 cpux := strconv.Itoa(i / fieldsCount)
135 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, value, cpux, cpuFields[i%fieldsCount]) 135 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, value, cpux, cpuFields[i%fieldsCount])
136 } 136 }
137 137
diff --git a/collector/cpu_linux.go b/collector/cpu_linux.go
index 1cb6f2c..f5e9ce8 100644
--- a/collector/cpu_linux.go
+++ b/collector/cpu_linux.go
@@ -106,7 +106,7 @@ func (c *cpuCollector) updateInfo(ch chan<- prometheus.Metric) error {
106 1, 106 1,
107 cpu.PhysicalID, 107 cpu.PhysicalID,
108 cpu.CoreID, 108 cpu.CoreID,
109 fmt.Sprintf("%d", cpu.Processor), 109 strconv.Itoa(int(cpu.Processor)),
110 cpu.VendorID, 110 cpu.VendorID,
111 cpu.CPUFamily, 111 cpu.CPUFamily,
112 cpu.Model, 112 cpu.Model,
@@ -202,7 +202,7 @@ func (c *cpuCollector) updateStat(ch chan<- prometheus.Metric) error {
202 } 202 }
203 203
204 for cpuID, cpuStat := range stats.CPU { 204 for cpuID, cpuStat := range stats.CPU {
205 cpuNum := fmt.Sprintf("%d", cpuID) 205 cpuNum := strconv.Itoa(cpuID)
206 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.User, cpuNum, "user") 206 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.User, cpuNum, "user")
207 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Nice, cpuNum, "nice") 207 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.Nice, cpuNum, "nice")
208 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.System, cpuNum, "system") 208 ch <- prometheus.MustNewConstMetric(c.cpu, prometheus.CounterValue, cpuStat.System, cpuNum, "system")
diff --git a/collector/interrupts_openbsd.go b/collector/interrupts_openbsd.go
index 5a61e68..c9aae3c 100644
--- a/collector/interrupts_openbsd.go
+++ b/collector/interrupts_openbsd.go
@@ -108,7 +108,7 @@ func (c *interruptsCollector) Update(ch chan<- prometheus.Metric) error {
108 ch <- c.desc.mustNewConstMetric( 108 ch <- c.desc.mustNewConstMetric(
109 value, 109 value,
110 strconv.Itoa(cpuNo), 110 strconv.Itoa(cpuNo),
111 fmt.Sprintf("%d", interrupt.vector), 111 strconv.Itoa(interrupt.vector),
112 dev, 112 dev,
113 ) 113 )
114 } 114 }
diff --git a/collector/perf_linux.go b/collector/perf_linux.go
index 0e8a3cc..e8a52b4 100644
--- a/collector/perf_linux.go
+++ b/collector/perf_linux.go
@@ -14,8 +14,8 @@
14package collector 14package collector
15 15
16import ( 16import (
17 "fmt"
18 "runtime" 17 "runtime"
18 "strconv"
19 19
20 "github.com/go-kit/kit/log" 20 "github.com/go-kit/kit/log"
21 "github.com/hodgesds/perf-utils" 21 "github.com/hodgesds/perf-utils"
@@ -334,7 +334,7 @@ func (c *perfCollector) Update(ch chan<- prometheus.Metric) error {
334 334
335func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error { 335func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
336 for cpu, profiler := range c.perfHwProfilers { 336 for cpu, profiler := range c.perfHwProfilers {
337 cpuStr := fmt.Sprintf("%d", cpu) 337 cpuStr := strconv.Itoa(cpu)
338 hwProfile, err := profiler.Profile() 338 hwProfile, err := profiler.Profile()
339 if err != nil { 339 if err != nil {
340 return err 340 return err
@@ -405,7 +405,7 @@ func (c *perfCollector) updateHardwareStats(ch chan<- prometheus.Metric) error {
405 405
406func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error { 406func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
407 for cpu, profiler := range c.perfSwProfilers { 407 for cpu, profiler := range c.perfSwProfilers {
408 cpuStr := fmt.Sprintf("%d", cpu) 408 cpuStr := strconv.Itoa(cpu)
409 swProfile, err := profiler.Profile() 409 swProfile, err := profiler.Profile()
410 if err != nil { 410 if err != nil {
411 return err 411 return err
@@ -460,7 +460,7 @@ func (c *perfCollector) updateSoftwareStats(ch chan<- prometheus.Metric) error {
460 460
461func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error { 461func (c *perfCollector) updateCacheStats(ch chan<- prometheus.Metric) error {
462 for cpu, profiler := range c.perfCacheProfilers { 462 for cpu, profiler := range c.perfCacheProfilers {
463 cpuStr := fmt.Sprintf("%d", cpu) 463 cpuStr := strconv.Itoa(cpu)
464 cacheProfile, err := profiler.Profile() 464 cacheProfile, err := profiler.Profile()
465 if err != nil { 465 if err != nil {
466 return err 466 return err