Skip to content

Commit ff3e175

Browse files
authored
Sample logging for no broadcasts (#61)
In production occasionally a node will have an issue and this can generate a LOT of logs. Sampling should reduce the volume but still make it pretty obvious that something is wrong.
1 parent 0796c35 commit ff3e175

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

services_delegate.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package main
22

33
import (
44
"encoding/json"
5+
"math/rand"
56
"time"
67

78
"github.com/Nitro/memberlist"
89
"github.com/Nitro/sidecar/catalog"
910
"github.com/Nitro/sidecar/service"
10-
"github.com/armon/go-metrics"
11+
metrics "github.com/armon/go-metrics"
1112
"github.com/pquerna/ffjson/ffjson"
1213
log "github.com/sirupsen/logrus"
1314
)
@@ -200,7 +201,11 @@ func (d *servicesDelegate) packPacket(broadcasts [][]byte, limit int, overhead i
200201
// Don't warn on startup... it's fairly normal
201202
gracePeriod := time.Now().UTC().Add(0 - (5 * time.Second))
202203
if d.StartedAt.Before(gracePeriod) {
203-
log.Warnf("All messages were too long to fit! No broadcasts!")
204+
// Sample this so that we don't go apeshit logging when there is something
205+
// a bit blocked up. We'll log 1/50th of the time.
206+
if rand.Intn(50) == 1 {
207+
log.Warnf("All messages were too long to fit! No broadcasts!")
208+
}
204209
}
205210

206211
// There could be a scenario here where one hugely long broadcast could

0 commit comments

Comments
 (0)