Skip to content

Commit

Permalink
log LATENCY LATEST error only once
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver006 committed Mar 22, 2021
1 parent ed6a26b commit 2f95417
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions exporter/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package exporter

import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"net/http/httptest"
"os"
"regexp"
"strings"
"testing"

"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
)

func TestKeyspaceStringParser(t *testing.T) {
Expand Down
13 changes: 12 additions & 1 deletion exporter/latency.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package exporter

import (
"sync"

"github.com/gomodule/redigo/redis"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
)

var logErrOnce sync.Once

func (e *Exporter) extractLatencyMetrics(ch chan<- prometheus.Metric, c redis.Conn) {
reply, err := redis.Values(doRedisCmd(c, "LATENCY", "LATEST"))
if err != nil {
log.Errorf("cmd LATENCY LATEST, err: %s", err)
/*
this can be a little too verbose, see e.g. https://github.com/oliver006/redis_exporter/issues/495
we're logging this only once as an Error and always as Debugf()
*/
logErrOnce.Do(func() {
log.Errorf("WARNING, LOGGED ONCE ONLY: cmd LATENCY LATEST, err: %s", err)
})
log.Debugf("cmd LATENCY LATEST, err: %s", err)
return
}

Expand Down

0 comments on commit 2f95417

Please sign in to comment.