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

Log duration of AS request handling #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions appservice/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ func (as *AppService) consumeWebsocket(stopFunc func(error), ws *websocket.Conn)
as.websocketRequestsLock.RUnlock()
} else {
as.Log.Debugfln("Received command request %s %d", msg.Command, msg.ReqID)
startTime := time.Now()
as.websocketHandlersLock.RLock()
handler, ok := as.websocketHandlers[msg.Command]
as.websocketHandlersLock.RUnlock()
duration := time.Now().Sub(startTime)
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the wrong place, handling only happens when handler(msg.WebsocketCommand) is called

Copy link
Member Author

Choose a reason for hiding this comment

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

🤦 too early! 46e905f

if !ok {
handler = as.unknownCommandHandler
}
Expand All @@ -301,9 +303,9 @@ func (as *AppService) consumeWebsocket(stopFunc func(error), ws *websocket.Conn)
if err != nil {
as.Log.Warnfln("Failed to send response to %s %d: %v", msg.Command, msg.ReqID, err)
} else if okResp {
as.Log.Debugfln("Sent success response to %s %d", msg.Command, msg.ReqID)
as.Log.Debugfln("Sent success response to %s %d (took %s)", msg.Command, msg.ReqID, duration)
} else {
as.Log.Debugfln("Sent error response to %s %d", msg.Command, msg.ReqID)
as.Log.Debugfln("Sent error response to %s %d (took %s)", msg.Command, msg.ReqID, duration)
}
}()
}
Expand Down