File tree Expand file tree Collapse file tree 5 files changed +13
-3
lines changed Expand file tree Collapse file tree 5 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import (
17
17
"os/exec"
18
18
"os/user"
19
19
"path/filepath"
20
+ "reflect"
20
21
"runtime"
21
22
"sort"
22
23
"strconv"
@@ -155,6 +156,7 @@ type agent struct {
155
156
156
157
network * tailnet.Conn
157
158
connStatsChan chan * agentsdk.Stats
159
+ latestStat atomic.Pointer [agentsdk.Stats ]
158
160
159
161
connCountVSCode atomic.Int64
160
162
connCountJetBrains atomic.Int64
@@ -1241,6 +1243,13 @@ func (a *agent) startReportingConnectionStats(ctx context.Context) {
1241
1243
// Convert from microseconds to milliseconds.
1242
1244
stats .ConnectionMedianLatencyMS /= 1000
1243
1245
1246
+ lastStat := a .latestStat .Load ()
1247
+ if lastStat != nil && reflect .DeepEqual (lastStat , stats ) {
1248
+ a .logger .Info (ctx , "skipping stat because nothing changed" )
1249
+ return
1250
+ }
1251
+ a .latestStat .Store (stats )
1252
+
1244
1253
select {
1245
1254
case a .connStatsChan <- stats :
1246
1255
default :
Original file line number Diff line number Diff line change @@ -156,7 +156,6 @@ func TestAgent_Stats_Magic(t *testing.T) {
156
156
require .Eventuallyf (t , func () bool {
157
157
var ok bool
158
158
s , ok = <- stats
159
- fmt .Printf ("WE GOT STATS %+v\n " , s )
160
159
return ok && s .ConnectionCount > 0 && s .RxBytes > 0 && s .TxBytes > 0 &&
161
160
// Ensure that the connection didn't count as a "normal" SSH session.
162
161
// This was a special one, so it should be labeled specially in the stats!
Original file line number Diff line number Diff line change @@ -406,7 +406,7 @@ func newConfig() *codersdk.DeploymentConfig {
406
406
Usage : "How frequently agent stats are recorded" ,
407
407
Flag : "agent-stats-refresh-interval" ,
408
408
Hidden : true ,
409
- Default : time .Minute ,
409
+ Default : 30 * time .Second ,
410
410
},
411
411
AgentFallbackTroubleshootingURL : & codersdk.DeploymentConfigField [string ]{
412
412
Name : "Agent Fallback Troubleshooting URL" ,
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ replace github.com/tcnksm/go-httpstat => github.com/kylecarbs/go-httpstat v0.0.0
40
40
41
41
// There are a few minor changes we make to Tailscale that we're slowly upstreaming. Compare here:
42
42
// https://github.com/tailscale/tailscale/compare/main...coder:tailscale:main
43
- replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20230301203426-fb16ae7c5bba
43
+ replace tailscale.com => github.com/coder/tailscale v1.1.1-0.20230306185501-ae6dbba0a7ee
44
44
45
45
// Switch to our fork that imports fixes from http://github.com/tailscale/ssh.
46
46
// See: https://github.com/coder/coder/issues/3371
Original file line number Diff line number Diff line change @@ -407,6 +407,8 @@ github.com/coder/tailscale v1.1.1-0.20230228220447-d27e5d3056e9 h1:bFcFXLUUi+cwg
407
407
github.com/coder/tailscale v1.1.1-0.20230228220447-d27e5d3056e9 /go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA =
408
408
github.com/coder/tailscale v1.1.1-0.20230301203426-fb16ae7c5bba h1:JOD5pqNtiz9lkSX74PY2BJOyNqsBmvGUjFGIuECtG+o =
409
409
github.com/coder/tailscale v1.1.1-0.20230301203426-fb16ae7c5bba /go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA =
410
+ github.com/coder/tailscale v1.1.1-0.20230306185501-ae6dbba0a7ee h1:0o3Q9u7+r7zNPaRCW/bLXuxPv8ukExtyig7RZfzcs8A =
411
+ github.com/coder/tailscale v1.1.1-0.20230306185501-ae6dbba0a7ee /go.mod h1:jpg+77g19FpXL43U1VoIqoSg1K/Vh5CVxycGldQ8KhA =
410
412
github.com/coder/terraform-provider-coder v0.6.14 h1:NsJ1mo0MN1x/VyNLYmsgPUYn2JgzdVNZBqnj9OSIDgY =
411
413
github.com/coder/terraform-provider-coder v0.6.14 /go.mod h1:UIfU3bYNeSzJJvHyJ30tEKjD6Z9utloI+HUM/7n94CY =
412
414
github.com/containerd/aufs v0.0.0-20200908144142-dab0cbea06f4 /go.mod h1:nukgQABAEopAHvB6j7cnP5zJ+/3aVcE7hCYqvIwAHyE =
You can’t perform that action at this time.
0 commit comments