Skip to content

Sample logging for no broadcasts #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 7, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions services_delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package main

import (
"encoding/json"
"math/rand"
"time"

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

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