[#442] Use strconv.FormatBool instead of untyped conversion
ci/woodpecker/push/pre-commit Pipeline was successful Details

Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
pull/444/head
Alejandro Lopez 2023-06-13 14:19:33 +03:00 committed by Evgenii Stratonikov
parent 344d6b2ae1
commit fb8fee0c8e
4 changed files with 14 additions and 12 deletions

View File

@ -1,7 +1,7 @@
package metrics package metrics
import ( import (
"fmt" "strconv"
"time" "time"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
@ -64,7 +64,7 @@ func newGCMetrics() *gcMetrics {
func (m *gcMetrics) AddRunDuration(shardID string, d time.Duration, success bool) { func (m *gcMetrics) AddRunDuration(shardID string, d time.Duration, success bool) {
m.runDuration.With(prometheus.Labels{ m.runDuration.With(prometheus.Labels{
gcShardID: shardID, gcShardID: shardID,
gcSuccess: fmt.Sprintf("%v", success), gcSuccess: strconv.FormatBool(success),
}).Add(d.Seconds()) }).Add(d.Seconds())
} }
@ -84,7 +84,7 @@ func (m *gcMetrics) AddDeletedCount(shardID string, deleted, failed uint64) {
func (m *gcMetrics) AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool, objectType string) { func (m *gcMetrics) AddExpiredObjectCollectionDuration(shardID string, d time.Duration, success bool, objectType string) {
m.expCollectDuration.With(prometheus.Labels{ m.expCollectDuration.With(prometheus.Labels{
gcShardID: shardID, gcShardID: shardID,
gcSuccess: fmt.Sprintf("%v", success), gcSuccess: strconv.FormatBool(success),
gcObjectType: objectType, gcObjectType: objectType,
}).Add(d.Seconds()) }).Add(d.Seconds())
} }

View File

@ -2,6 +2,7 @@ package metrics
import ( import (
"fmt" "fmt"
"strconv"
"time" "time"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
@ -46,7 +47,7 @@ func newMorphCacheMetrics() *morphCacheMetrics {
func (m *morphCacheMetrics) AddNNSContractHashDuration(success bool, d time.Duration) { func (m *morphCacheMetrics) AddNNSContractHashDuration(success bool, d time.Duration) {
m.nnsContractHashDuration.With( m.nnsContractHashDuration.With(
prometheus.Labels{ prometheus.Labels{
mcSuccess: fmt.Sprintf("%v", success), mcSuccess: strconv.FormatBool(success),
}, },
).Observe(float64(d)) ).Observe(float64(d))
} }
@ -54,7 +55,7 @@ func (m *morphCacheMetrics) AddNNSContractHashDuration(success bool, d time.Dura
func (m *morphCacheMetrics) AddGroupKeyDuration(success bool, d time.Duration) { func (m *morphCacheMetrics) AddGroupKeyDuration(success bool, d time.Duration) {
m.groupKeyDuration.With( m.groupKeyDuration.With(
prometheus.Labels{ prometheus.Labels{
mcSuccess: fmt.Sprintf("%v", success), mcSuccess: strconv.FormatBool(success),
}, },
).Observe(float64(d)) ).Observe(float64(d))
} }
@ -62,7 +63,7 @@ func (m *morphCacheMetrics) AddGroupKeyDuration(success bool, d time.Duration) {
func (m *morphCacheMetrics) AddTxHeightDuration(hash util.Uint256, success bool, d time.Duration) { func (m *morphCacheMetrics) AddTxHeightDuration(hash util.Uint256, success bool, d time.Duration) {
m.txHeightDuration.With( m.txHeightDuration.With(
prometheus.Labels{ prometheus.Labels{
mcSuccess: fmt.Sprintf("%v", success), mcSuccess: strconv.FormatBool(success),
}, },
).Observe(float64(d)) ).Observe(float64(d))
} }

View File

@ -1,7 +1,7 @@
package metrics package metrics
import ( import (
"fmt" "strconv"
"time" "time"
"git.frostfs.info/TrueCloudLab/frostfs-observability/metrics" "git.frostfs.info/TrueCloudLab/frostfs-observability/metrics"
@ -50,18 +50,18 @@ func newTreeServiceMetrics() *treeServiceMetrics {
func (m *treeServiceMetrics) AddReplicateTaskDuration(d time.Duration, success bool) { func (m *treeServiceMetrics) AddReplicateTaskDuration(d time.Duration, success bool) {
m.replicateTaskDuration.With(prometheus.Labels{ m.replicateTaskDuration.With(prometheus.Labels{
treeServiceLabelSuccess: fmt.Sprintf("%v", success), treeServiceLabelSuccess: strconv.FormatBool(success),
}).Observe(d.Seconds()) }).Observe(d.Seconds())
} }
func (m *treeServiceMetrics) AddReplicateWaitDuration(d time.Duration, success bool) { func (m *treeServiceMetrics) AddReplicateWaitDuration(d time.Duration, success bool) {
m.replicateWaitDuration.With(prometheus.Labels{ m.replicateWaitDuration.With(prometheus.Labels{
treeServiceLabelSuccess: fmt.Sprintf("%v", success), treeServiceLabelSuccess: strconv.FormatBool(success),
}).Observe(d.Seconds()) }).Observe(d.Seconds())
} }
func (m *treeServiceMetrics) AddSyncDuration(d time.Duration, success bool) { func (m *treeServiceMetrics) AddSyncDuration(d time.Duration, success bool) {
m.syncOpDuration.With(prometheus.Labels{ m.syncOpDuration.With(prometheus.Labels{
treeServiceLabelSuccess: fmt.Sprintf("%v", success), treeServiceLabelSuccess: strconv.FormatBool(success),
}).Observe(d.Seconds()) }).Observe(d.Seconds())
} }

View File

@ -2,6 +2,7 @@ package metrics
import ( import (
"fmt" "fmt"
"strconv"
"sync" "sync"
"time" "time"
@ -148,7 +149,7 @@ func (m *writeCacheMetrics) SetMode(shardID string, mode string) {
func (m *writeCacheMetrics) IncFlushCounter(shardID string, success bool, storageType string) { func (m *writeCacheMetrics) IncFlushCounter(shardID string, success bool, storageType string) {
m.flushCounter.With(prometheus.Labels{ m.flushCounter.With(prometheus.Labels{
wcShardID: shardID, wcShardID: shardID,
wcSuccess: fmt.Sprintf("%v", success), wcSuccess: strconv.FormatBool(success),
wcStorage: storageType, wcStorage: storageType,
}).Inc() }).Inc()
} }
@ -164,7 +165,7 @@ func setWriteCacheDuration(m *prometheus.HistogramVec, shardID string, success b
m.With( m.With(
prometheus.Labels{ prometheus.Labels{
wcShardID: shardID, wcShardID: shardID,
wcSuccess: fmt.Sprintf("%v", success), wcSuccess: strconv.FormatBool(success),
wcStorage: storageType, wcStorage: storageType,
}, },
).Observe(d.Seconds()) ).Observe(d.Seconds())