Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon authored and Gordon committed Jul 15, 2024
1 parent 3343b80 commit 0711ac5
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions telemetry/prometheus/metrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package prometheus

import (
"errors"
"fmt"
"strings"
"sync"
Expand Down Expand Up @@ -145,10 +146,10 @@ func (p *metrics) Count(name string, value int64, tags ...string) {
}, labels)
if err := prometheus.Register(counterVec); err != nil {
// In case of concurrent registration, get the one that has already registered
var existingCollector prometheus.AlreadyRegisteredError
if existingCollector.Error() == err.Error() {
var alreadyRegisteredError prometheus.AlreadyRegisteredError
if errors.As(err, &alreadyRegisteredError) {
//nolint:errcheck // OK
counterVec = existingCollector.ExistingCollector.(*prometheus.CounterVec)
counterVec = alreadyRegisteredError.ExistingCollector.(*prometheus.CounterVec)
} else {
// Otherwise we should panic to fail fast
panic(err)
Expand Down Expand Up @@ -183,10 +184,10 @@ func (p *metrics) IncMonotonic(name string, tags ...string) {
}, labels)
if err := prometheus.Register(counterVec); err != nil {
// In case of concurrent registration, get the one that has already registered
var existingCollector prometheus.AlreadyRegisteredError
if existingCollector.Error() == err.Error() {
var alreadyRegisteredError prometheus.AlreadyRegisteredError
if errors.As(err, &alreadyRegisteredError) {
//nolint:errcheck // OK
counterVec = existingCollector.ExistingCollector.(*prometheus.CounterVec)
counterVec = alreadyRegisteredError.ExistingCollector.(*prometheus.CounterVec)
} else {
// Otherwise we should panic to fail fast
panic(err)
Expand Down Expand Up @@ -257,10 +258,10 @@ func (p *metrics) Time(name string, value time.Duration, tags ...string) {
}, labels)
if err := prometheus.Register(summaryVec); err != nil {
// In case of concurrent registration, get the one that has already registered
var existingCollector prometheus.AlreadyRegisteredError
if existingCollector.Error() == err.Error() {
var alreadyRegisteredError prometheus.AlreadyRegisteredError
if errors.As(err, &alreadyRegisteredError) {
//nolint:errcheck // OK
summaryVec = existingCollector.ExistingCollector.(*prometheus.SummaryVec)
summaryVec = alreadyRegisteredError.ExistingCollector.(*prometheus.SummaryVec)
} else {
// Otherwise we should panic to fail fast
panic(err)
Expand Down

0 comments on commit 0711ac5

Please sign in to comment.