Skip to content

Commit 1c42a20

Browse files
authored
chore: add debugging to agent stats report (coder#5395)
1 parent d72d312 commit 1c42a20

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

coderd/workspaceagents.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,21 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
782782
return
783783
}
784784

785+
api.Logger.Debug(ctx, "read stats report",
786+
slog.F("interval", api.AgentStatsRefreshInterval),
787+
slog.F("agent", workspaceAgent.ID),
788+
slog.F("workspace", workspace.ID),
789+
slog.F("payload", req),
790+
)
791+
785792
activityBumpWorkspace(api.Logger.Named("activity_bump"), api.Database, workspace.ID)
786793

794+
payload, err := json.Marshal(req)
795+
if err != nil {
796+
api.Logger.Error(ctx, "marshal agent stats report", slog.Error(err))
797+
payload = json.RawMessage("{}")
798+
}
799+
787800
now := database.Now()
788801
_, err = api.Database.InsertAgentStat(ctx, database.InsertAgentStatParams{
789802
ID: uuid.New(),
@@ -792,7 +805,7 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
792805
WorkspaceID: workspace.ID,
793806
UserID: workspace.OwnerID,
794807
TemplateID: workspace.TemplateID,
795-
Payload: json.RawMessage("{}"),
808+
Payload: payload,
796809
})
797810
if err != nil {
798811
httpapi.InternalServerError(rw, err)

0 commit comments

Comments
 (0)