mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Log device ID after requests
This commit is contained in:
parent
bdcffda18f
commit
2829a7ae45
@ -16,6 +16,7 @@ var (
|
||||
// logging metadata for a single request
|
||||
type data struct {
|
||||
userID string
|
||||
deviceID string
|
||||
since int64
|
||||
next int64
|
||||
numRooms int
|
||||
@ -37,13 +38,14 @@ func RequestContext(ctx context.Context) context.Context {
|
||||
}
|
||||
|
||||
// add the user ID to this request context. Need to have called RequestContext first.
|
||||
func SetRequestContextUserID(ctx context.Context, userID string) {
|
||||
func SetRequestContextUserID(ctx context.Context, userID, deviceID string) {
|
||||
d := ctx.Value(ctxData)
|
||||
if d == nil {
|
||||
return
|
||||
}
|
||||
da := d.(*data)
|
||||
da.userID = userID
|
||||
da.deviceID = deviceID
|
||||
if hub := sentry.GetHubFromContext(ctx); hub != nil {
|
||||
sentry.ConfigureScope(func(scope *sentry.Scope) {
|
||||
scope.SetUser(sentry.User{Username: userID})
|
||||
@ -79,6 +81,9 @@ func DecorateLogger(ctx context.Context, l *zerolog.Event) *zerolog.Event {
|
||||
if da.userID != "" {
|
||||
l = l.Str("u", da.userID)
|
||||
}
|
||||
if da.deviceID != "" {
|
||||
l = l.Str("dev", da.deviceID)
|
||||
}
|
||||
if da.since >= 0 {
|
||||
l = l.Int64("p", da.since)
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ func (h *SyncLiveHandler) serve(w http.ResponseWriter, req *http.Request) error
|
||||
return herr
|
||||
}
|
||||
requestBody.SetPos(cpos)
|
||||
internal.SetRequestContextUserID(req.Context(), conn.UserID)
|
||||
internal.SetRequestContextUserID(req.Context(), conn.UserID, conn.DeviceID)
|
||||
log := hlog.FromRequest(req).With().Str("user", conn.UserID).Int64("pos", cpos).Logger()
|
||||
|
||||
var timeout int
|
||||
|
Loading…
x
Reference in New Issue
Block a user