Skip to content

Commit 32a0859

Browse files
feat: instrument connection upgrade time (#12)
1 parent 97dd511 commit 32a0859

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

services/rest/websocket/connection/upgrader.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func NewUpgrader(conf UpgraderConfig) *Upgrader {
5959
}
6060

6161
func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request) (Conn, error) {
62+
start := time.Now()
6263
identifier := u.newIdentifier(r.Header)
6364
logger.Debug(fmt.Sprintf("%s connected at %v", identifier, time.Now()))
6465

@@ -90,7 +91,8 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request) (Conn, error)
9091

9192
u.setUpControlHandlers(conn, identifier)
9293
metrics.Increment("user_connection_success_total", fmt.Sprintf("conn_group=%s", identifier.Group))
93-
94+
metrics.Timing("user_connection_upgrade_duration_ms", time.Since(start).Milliseconds(),
95+
fmt.Sprintf("conn_group=%s", identifier.Group))
9496
return Conn{
9597
Identifier: identifier,
9698
conn: conn,

0 commit comments

Comments
 (0)