Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c84fb7

Browse files
authored
fix(coderd/agentapi): always write agent stats when provided (#12699)
1 parentbd6ad88 commit9c84fb7

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

‎coderd/agentapi/stats.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func (a *StatsAPI) now() time.Time {
4747
}
4848

4949
func (a*StatsAPI)UpdateStats(ctx context.Context,req*agentproto.UpdateStatsRequest) (*agentproto.UpdateStatsResponse,error) {
50-
// An empty stat means it's just looking for the report interval.
5150
res:=&agentproto.UpdateStatsResponse{
5251
ReportInterval:durationpb.New(a.AgentStatsRefreshInterval),
5352
}
54-
ifreq.Stats==nil||len(req.Stats.ConnectionsByProto)==0 {
53+
// An empty stat means it's just looking for the report interval.
54+
ifreq.Stats==nil {
5555
returnres,nil
5656
}
5757

‎coderd/agentapi/stats_test.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ func TestUpdateStates(t *testing.T) {
222222

223223
req=&agentproto.UpdateStatsRequest{
224224
Stats:&agentproto.Stats{
225-
ConnectionsByProto:map[string]int64{
226-
"tcp":1,
227-
},
225+
ConnectionsByProto:map[string]int64{},
228226
ConnectionCount:0,
229227
ConnectionMedianLatencyMs:23,
230228
},
@@ -262,16 +260,14 @@ func TestUpdateStates(t *testing.T) {
262260
require.NoError(t,err)
263261
})
264262

265-
t.Run("NoConnectionsByProto",func(t*testing.T) {
263+
t.Run("NoStats",func(t*testing.T) {
266264
t.Parallel()
267265

268266
var (
269267
dbM=dbmock.NewMockStore(gomock.NewController(t))
270268
ps=pubsub.NewInMemory()
271269
req=&agentproto.UpdateStatsRequest{
272-
Stats:&agentproto.Stats{
273-
ConnectionsByProto:map[string]int64{},// len() == 0
274-
},
270+
Stats:nil,
275271
}
276272
)
277273
api:= agentapi.StatsAPI{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp