@@ -14,6 +14,7 @@ import (
14
14
"github.com/google/uuid"
15
15
"github.com/hashicorp/yamux"
16
16
"github.com/tabbed/pqtype"
17
+ "go.opentelemetry.io/otel/trace"
17
18
"golang.org/x/xerrors"
18
19
"inet.af/netaddr"
19
20
"nhooyr.io/websocket"
@@ -108,6 +109,10 @@ func (api *API) workspaceAgentDial(rw http.ResponseWriter, r *http.Request) {
108
109
_ = conn .Close (websocket .StatusAbnormalClosure , err .Error ())
109
110
return
110
111
}
112
+
113
+ // end span so we don't get long lived trace data
114
+ trace .SpanFromContext (ctx ).End ()
115
+
111
116
err = peerbroker .ProxyListen (ctx , session , peerbroker.ProxyOptions {
112
117
ChannelID : workspaceAgent .ID .String (),
113
118
Logger : api .Logger .Named ("peerbroker-proxy-dial" ),
@@ -270,6 +275,9 @@ func (api *API) workspaceAgentListen(rw http.ResponseWriter, r *http.Request) {
270
275
return
271
276
}
272
277
278
+ // end span so we don't get long lived trace data
279
+ trace .SpanFromContext (ctx ).End ()
280
+
273
281
api .Logger .Info (ctx , "accepting agent" , slog .F ("resource" , resource ), slog .F ("agent" , workspaceAgent ))
274
282
275
283
ticker := time .NewTicker (api .AgentConnectionUpdateFrequency )
@@ -357,7 +365,8 @@ func (api *API) workspaceAgentTurn(rw http.ResponseWriter, r *http.Request) {
357
365
}
358
366
359
367
ctx , wsNetConn := websocketNetConn (r .Context (), wsConn , websocket .MessageBinary )
360
- defer wsNetConn .Close () // Also closes conn.
368
+ defer wsNetConn .Close () // Also closes conn.
369
+ trace .SpanFromContext (ctx ).End () // end span so we don't get long lived trace data
361
370
362
371
api .Logger .Debug (ctx , "accepting turn connection" , slog .F ("remote-address" , r .RemoteAddr ), slog .F ("local-address" , localAddress ))
363
372
select {
@@ -571,6 +580,9 @@ func (api *API) workspaceAgentWireguardListener(rw http.ResponseWriter, r *http.
571
580
}
572
581
defer subCancel ()
573
582
583
+ // end span so we don't get long lived trace data
584
+ trace .SpanFromContext (ctx ).End ()
585
+
574
586
// Wait for the connection to close or the client to send a message.
575
587
//nolint:dogsled
576
588
_ , _ , _ = conn .Reader (ctx )
0 commit comments