Skip to content
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

Report a metric for the size of gappy state blocks #194

Merged
merged 3 commits into from
Jul 10, 2023
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
23 changes: 22 additions & 1 deletion sync2/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type PollerMap struct {
executorRunning bool
processHistogramVec *prometheus.HistogramVec
timelineSizeHistogramVec *prometheus.HistogramVec
gappyStateSizeVec *prometheus.HistogramVec
numOutstandingSyncReqsGauge prometheus.Gauge
totalNumPollsCounter prometheus.Counter
}
Expand Down Expand Up @@ -121,6 +122,14 @@ func NewPollerMap(v2Client Client, enablePrometheus bool) *PollerMap {
Buckets: []float64{0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0},
}, []string{"limited"})
prometheus.MustRegister(pm.timelineSizeHistogramVec)
pm.gappyStateSizeVec = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: "sliding_sync",
Subsystem: "poller",
Name: "gappy_state_size",
Help: "Number of events in a state block during a sync v2 gappy sync",
Buckets: []float64{1.0, 10.0, 100.0, 1000.0, 10000.0},
}, nil)
prometheus.MustRegister(pm.gappyStateSizeVec)
pm.totalNumPollsCounter = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "sliding_sync",
Subsystem: "poller",
Expand Down Expand Up @@ -156,6 +165,9 @@ func (h *PollerMap) Terminate() {
if h.timelineSizeHistogramVec != nil {
prometheus.Unregister(h.timelineSizeHistogramVec)
}
if h.gappyStateSizeVec != nil {
prometheus.Unregister(h.gappyStateSizeVec)
}
if h.totalNumPollsCounter != nil {
prometheus.Unregister(h.totalNumPollsCounter)
}
Expand Down Expand Up @@ -221,6 +233,7 @@ func (h *PollerMap) EnsurePolling(pid PollerID, accessToken, v2since string, isS
poller = newPoller(pid, accessToken, h.v2Client, h, logger, !needToWait && !isStartup)
poller.processHistogramVec = h.processHistogramVec
poller.timelineSizeVec = h.timelineSizeHistogramVec
poller.gappyStateSizeVec = h.gappyStateSizeVec
poller.numOutstandingSyncReqs = h.numOutstandingSyncReqsGauge
poller.totalNumPolls = h.totalNumPollsCounter
go poller.Poll(v2since)
Expand Down Expand Up @@ -377,6 +390,7 @@ type poller struct {
pollHistogramVec *prometheus.HistogramVec
processHistogramVec *prometheus.HistogramVec
timelineSizeVec *prometheus.HistogramVec
gappyStateSizeVec *prometheus.HistogramVec
numOutstandingSyncReqs prometheus.Gauge
totalNumPolls prometheus.Counter
}
Expand Down Expand Up @@ -433,7 +447,7 @@ func (p *poller) Poll(since string) {
defer func() {
panicErr := recover()
if panicErr != nil {
logger.Error().Str("user", p.userID).Str("device", p.deviceID).Msg(string(debug.Stack()))
logger.Error().Str("user", p.userID).Str("device", p.deviceID).Msgf("%s. Traceback:\n%s", panicErr, debug.Stack())
internal.GetSentryHubFromContextOrDefault(ctx).RecoverWithContext(ctx, panicErr)
}
p.receiver.OnTerminated(ctx, p.userID, p.deviceID)
Expand Down Expand Up @@ -741,3 +755,10 @@ func (p *poller) trackTimelineSize(size int, limited bool) {
}
p.timelineSizeVec.WithLabelValues(label).Observe(float64(size))
}

func (p *poller) trackGappyStateSize(size int) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You never call this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦 committed locally but not pushed.

if p.gappyStateSizeVec == nil {
return
}
p.gappyStateSizeVec.WithLabelValues().Observe(float64(size))
}
Loading