mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Track buffer sizes in summary line
This commit is contained in:
parent
7dc999a44e
commit
3536307204
@ -2,6 +2,8 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
@ -17,6 +19,7 @@ var (
|
||||
type data struct {
|
||||
userID string
|
||||
deviceID string
|
||||
bufferSummary string
|
||||
since int64
|
||||
next int64
|
||||
numRooms int
|
||||
@ -53,6 +56,15 @@ func SetRequestContextUserID(ctx context.Context, userID, deviceID string) {
|
||||
}
|
||||
}
|
||||
|
||||
func SetConnBufferInfo(ctx context.Context, bufferLen, nextLen, bufferCap int) {
|
||||
d := ctx.Value(ctxData)
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
da := d.(*data)
|
||||
da.bufferSummary = fmt.Sprintf("%d/%d/%d", bufferLen, nextLen, bufferCap)
|
||||
}
|
||||
|
||||
func SetRequestContextResponseInfo(
|
||||
ctx context.Context, since, next int64, numRooms int, txnID string, numToDeviceEvents, numGlobalAccountData int,
|
||||
numChangedDevices, numLeftDevices int,
|
||||
@ -108,5 +120,8 @@ func DecorateLogger(ctx context.Context, l *zerolog.Event) *zerolog.Event {
|
||||
if da.numLeftDevices > 0 {
|
||||
l = l.Int("dl-l", da.numLeftDevices)
|
||||
}
|
||||
if da.bufferSummary != "" {
|
||||
l = l.Str("b", da.bufferSummary)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ func (s *connStateLive) liveUpdate(
|
||||
if req.TimeoutMSecs() < 100 {
|
||||
req.SetTimeoutMSecs(100)
|
||||
}
|
||||
startBufferSize := len(s.updates)
|
||||
// block until we get a new event, with appropriate timeout
|
||||
startTime := time.Now()
|
||||
hasLiveStreamed := false
|
||||
@ -104,6 +105,9 @@ func (s *connStateLive) liveUpdate(
|
||||
}
|
||||
|
||||
log.Trace().Bool("live_streamed", hasLiveStreamed).Msg("liveUpdate: returning")
|
||||
|
||||
internal.SetConnBufferInfo(ctx, startBufferSize, len(s.updates), cap(s.updates))
|
||||
|
||||
// TODO: op consolidation
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user