mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Add more logging to response lines
This commit is contained in:
parent
13673175b5
commit
8b6f48a24b
@ -20,6 +20,7 @@ type data struct {
|
|||||||
userID string
|
userID string
|
||||||
deviceID string
|
deviceID string
|
||||||
bufferSummary string
|
bufferSummary string
|
||||||
|
connID string
|
||||||
since int64
|
since int64
|
||||||
next int64
|
next int64
|
||||||
numRooms int
|
numRooms int
|
||||||
@ -28,6 +29,9 @@ type data struct {
|
|||||||
numGlobalAccountData int
|
numGlobalAccountData int
|
||||||
numChangedDevices int
|
numChangedDevices int
|
||||||
numLeftDevices int
|
numLeftDevices int
|
||||||
|
numLists int
|
||||||
|
roomSubs int
|
||||||
|
roomUnsubs int
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare a request context so it can contain syncv3 info
|
// prepare a request context so it can contain syncv3 info
|
||||||
@ -67,7 +71,7 @@ func SetConnBufferInfo(ctx context.Context, bufferLen, nextLen, bufferCap int) {
|
|||||||
|
|
||||||
func SetRequestContextResponseInfo(
|
func SetRequestContextResponseInfo(
|
||||||
ctx context.Context, since, next int64, numRooms int, txnID string, numToDeviceEvents, numGlobalAccountData int,
|
ctx context.Context, since, next int64, numRooms int, txnID string, numToDeviceEvents, numGlobalAccountData int,
|
||||||
numChangedDevices, numLeftDevices int,
|
numChangedDevices, numLeftDevices int, connID string, numLists int, roomSubs, roomUnsubs int,
|
||||||
) {
|
) {
|
||||||
d := ctx.Value(ctxData)
|
d := ctx.Value(ctxData)
|
||||||
if d == nil {
|
if d == nil {
|
||||||
@ -82,6 +86,10 @@ func SetRequestContextResponseInfo(
|
|||||||
da.numGlobalAccountData = numGlobalAccountData
|
da.numGlobalAccountData = numGlobalAccountData
|
||||||
da.numChangedDevices = numChangedDevices
|
da.numChangedDevices = numChangedDevices
|
||||||
da.numLeftDevices = numLeftDevices
|
da.numLeftDevices = numLeftDevices
|
||||||
|
da.connID = connID
|
||||||
|
da.numLists = numLists
|
||||||
|
da.roomSubs = roomSubs
|
||||||
|
da.roomUnsubs = roomUnsubs
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecorateLogger(ctx context.Context, l *zerolog.Event) *zerolog.Event {
|
func DecorateLogger(ctx context.Context, l *zerolog.Event) *zerolog.Event {
|
||||||
@ -123,5 +131,16 @@ func DecorateLogger(ctx context.Context, l *zerolog.Event) *zerolog.Event {
|
|||||||
if da.bufferSummary != "" {
|
if da.bufferSummary != "" {
|
||||||
l = l.Str("b", da.bufferSummary)
|
l = l.Str("b", da.bufferSummary)
|
||||||
}
|
}
|
||||||
|
if da.roomSubs > 0 {
|
||||||
|
l = l.Int("sub", da.roomSubs)
|
||||||
|
}
|
||||||
|
if da.roomUnsubs > 0 {
|
||||||
|
l = l.Int("usub", da.roomUnsubs)
|
||||||
|
}
|
||||||
|
if da.numLists > 0 {
|
||||||
|
l = l.Int("l", da.numLists)
|
||||||
|
}
|
||||||
|
// always log the connection ID so we know when it isn't set
|
||||||
|
l = l.Str("c", da.connID)
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ func (h *SyncLiveHandler) serve(w http.ResponseWriter, req *http.Request) error
|
|||||||
}
|
}
|
||||||
internal.SetRequestContextResponseInfo(
|
internal.SetRequestContextResponseInfo(
|
||||||
req.Context(), cpos, resp.PosInt(), len(resp.Rooms), requestBody.TxnID, numToDeviceEvents, numGlobalAccountData,
|
req.Context(), cpos, resp.PosInt(), len(resp.Rooms), requestBody.TxnID, numToDeviceEvents, numGlobalAccountData,
|
||||||
numChangedDevices, numLeftDevices,
|
numChangedDevices, numLeftDevices, requestBody.ConnID, len(requestBody.Lists), len(requestBody.RoomSubscriptions), len(requestBody.UnsubscribeRooms),
|
||||||
)
|
)
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
@ -21,9 +21,8 @@ type Response struct {
|
|||||||
Rooms map[string]Room `json:"rooms"`
|
Rooms map[string]Room `json:"rooms"`
|
||||||
Extensions extensions.Response `json:"extensions"`
|
Extensions extensions.Response `json:"extensions"`
|
||||||
|
|
||||||
Pos string `json:"pos"`
|
Pos string `json:"pos"`
|
||||||
TxnID string `json:"txn_id,omitempty"`
|
TxnID string `json:"txn_id,omitempty"`
|
||||||
Session string `json:"session_id,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResponseList struct {
|
type ResponseList struct {
|
||||||
@ -68,9 +67,8 @@ func (r *Response) UnmarshalJSON(b []byte) error {
|
|||||||
} `json:"lists"`
|
} `json:"lists"`
|
||||||
Extensions extensions.Response `json:"extensions"`
|
Extensions extensions.Response `json:"extensions"`
|
||||||
|
|
||||||
Pos string `json:"pos"`
|
Pos string `json:"pos"`
|
||||||
TxnID string `json:"txn_id,omitempty"`
|
TxnID string `json:"txn_id,omitempty"`
|
||||||
Session string `json:"session_id,omitempty"`
|
|
||||||
}{}
|
}{}
|
||||||
if err := json.Unmarshal(b, &temporary); err != nil {
|
if err := json.Unmarshal(b, &temporary); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -78,7 +76,6 @@ func (r *Response) UnmarshalJSON(b []byte) error {
|
|||||||
r.Rooms = temporary.Rooms
|
r.Rooms = temporary.Rooms
|
||||||
r.Pos = temporary.Pos
|
r.Pos = temporary.Pos
|
||||||
r.TxnID = temporary.TxnID
|
r.TxnID = temporary.TxnID
|
||||||
r.Session = temporary.Session
|
|
||||||
r.Extensions = temporary.Extensions
|
r.Extensions = temporary.Extensions
|
||||||
r.Lists = make(map[string]ResponseList, len(temporary.Lists))
|
r.Lists = make(map[string]ResponseList, len(temporary.Lists))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user