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

Commit22d4860

Browse files
committed
fix(coderd/agentapi): always write agent stats when provided
Previously we were discarding agent stats due to the length ofconnections by proto being zero.
1 parent131d0bd commit22d4860

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,14 @@ func TestUpdateStates(t *testing.T) {
262262
require.NoError(t,err)
263263
})
264264

265-
t.Run("NoConnectionsByProto",func(t*testing.T) {
265+
t.Run("NoStats",func(t*testing.T) {
266266
t.Parallel()
267267

268268
var (
269269
dbM=dbmock.NewMockStore(gomock.NewController(t))
270270
ps=pubsub.NewInMemory()
271271
req=&agentproto.UpdateStatsRequest{
272-
Stats:&agentproto.Stats{
273-
ConnectionsByProto:map[string]int64{},// len() == 0
274-
},
272+
Stats:nil,
275273
}
276274
)
277275
api:= agentapi.StatsAPI{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp