8000 added logging to long lived connection opening functions · coder/coder@66e2c3e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 66e2c3e

Browse files
committed
added logging to long lived connection opening functions
1 parent 7500ef5 commit 66e2c3e

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

coderd/inboxnotifications.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ func (api *API) watchInboxNotifications(rw http.ResponseWriter, r *http.Request)
219219
encoder := wsjson.NewEncoder[codersdk.GetInboxNotificationResponse](conn, websocket.MessageText)
220220
defer encoder.Close(websocket.StatusNormalClosure)
221221

222+
// log the initial connection
223+
httpmw.FromContext(ctx).WriteLog(ctx, http.StatusAccepted)
224+
222225
for {
223226
select {
224227
case <-ctx.Done():

coderd/provisionerjobs.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,8 @@ func (f *logFollower) follow() {
554554
return
555555
}
556556

557-
// write the initial connection to the logs
558-
httpmw.FromContext(f.ctx).WriteLog(
559-
f.ctx, http.StatusAccepted)
557+
// log the initial connection
558+
httpmw.FromContext(f.ctx).WriteLog(f.ctx, http.StatusAccepted)
560559

561560
// no need to wait if the job is done
562561
if f.complete {

coderd/workspaceagents.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ func (api *API) workspaceAgentLogs(rw http.ResponseWriter, r *http.Request) {
555555
t := time.NewTicker(recheckInterval)
556556
defer t.Stop()
557557

558+
// log the initial connection
559+
httpmw.FromContext(ctx).WriteLog(ctx, http.StatusAccepted)
560+
558561
go func() {
559562
defer func() {
560563
logger.Debug(ctx, "end log streaming loop")
@@ -928,6 +931,9 @@ func (api *API) derpMapUpdates(rw http.ResponseWriter, r *http.Request) {
928931
encoder := wsjson.NewEncoder[*tailcfg.DERPMap](ws, websocket.MessageBinary)
929932
defer encoder.Close(websocket.StatusGoingAway)
930933

934+
// log the initial connection
935+
httpmw.FromContext(ctx).WriteLog(ctx, http.StatusAccepted)
936+
931937
go func(ctx context.Context) {
932938
// TODO(mafredri): Is this too frequent? Use separate ping disconnect timeout?
933939
t := time.NewTicker(api.AgentConnectionUpdateFrequency)
@@ -1315,6 +1321,9 @@ func (api *API) watchWorkspaceAgentMetadata(
13151321
sendTicker := time.NewTicker(sendInterval)
13161322
defer sendTicker.Stop()
13171323

1324+
// log the initial connection
1325+
httpmw.FromContext(ctx).WriteLog(ctx, http.StatusAccepted)
1326+
13181327
// Send initial metadata.
13191328
sendMetadata()
13201329

0 commit comments

Comments
 (0)
0