-
Notifications
You must be signed in to change notification settings - Fork 894
feat(site): add agent connection timings #15276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
8f15ca1
8ac895f
124d149
0ff2be9
d00a00b
69b181c
3e1170c
ab8792f
0b685a9
709b669
d9fc453
1bed074
4bd6538
c368a57
f59a87d
91be0dc
044f6e5
e8bbecd
e1a61d8
ce6f507
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -957,9 +957,23 @@ func (api *API) buildTimings(ctx context.Context, build database.WorkspaceBuild) | |
return codersdk.WorkspaceBuildTimings{}, xerrors.Errorf("fetching workspace agent script timings: %w", err) | ||
} | ||
|
||
resources, err := api.Database.GetWorkspaceResourcesByJobID(ctx, build.JobID) | ||
if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||
return codersdk.WorkspaceBuildTimings{}, xerrors.Errorf("fetching workspace resources: %w", err) | ||
} | ||
resourceIDs := make([]uuid.UUID, 0, len(resources)) | ||
for _, resource := range resources { | ||
resourceIDs = append(resourceIDs, resource.ID) | ||
} | ||
agents, err := api.Database.GetWorkspaceAgentsByResourceIDs(ctx, resourceIDs) | ||
if err != nil && !errors.Is(err, sql.ErrNoRows) { | ||
return codersdk.WorkspaceBuildTimings{}, xerrors.Errorf("fetching workspace agents: %w", err) | ||
} | ||
|
||
res := codersdk.WorkspaceBuildTimings{ | ||
ProvisionerTimings: make([]codersdk.ProvisionerTiming, 0, len(provisionerTimings)), | ||
AgentScriptTimings: make([]codersdk.AgentScriptTiming, 0, len(agentScriptTimings)), | ||
ProvisionerTimings: make([]codersdk.ProvisionerTiming, 0, len(provisionerTimings)), | ||
AgentScriptTimings: make([]codersdk.AgentScriptTiming, 0, len(agentScriptTimings)), | ||
AgentConnectionTimings: make([]codersdk.AgentConnectionTiming, 0, len(agents)), | ||
} | ||
|
||
for _, t := range provisionerTimings { | ||
|
@@ -975,12 +989,23 @@ func (api *API) buildTimings(ctx context.Context, build database.WorkspaceBuild) | |
} | ||
for _, t := range agentScriptTimings { | ||
res.AgentScriptTimings = append(res.AgentScriptTimings, codersdk.AgentScriptTiming{ | ||
StartedAt: t.StartedAt, | ||
EndedAt: t.EndedAt, | ||
ExitCode: t.ExitCode, | ||
Stage: string(t.Stage), | ||
Status: string(t.Status), | ||
DisplayName: t.DisplayName, | ||
StartedAt: t.StartedAt, | ||
EndedAt: t.EndedAt, | ||
ExitCode: t.ExitCode, | ||
Stage: string(t.Stage), | ||
Status: string(t.Status), | ||
DisplayName: t.DisplayName, | ||
WorkspaceAgentID: t.WorkspaceAgentID.String(), | ||
WorkspaceAgentName: t.WorkspaceAgentName, | ||
}) | ||
} | ||
for _, agent := range agents { | ||
dannykopping marked this conversation as resolved.
Show resolved
Hide resolved
|
||
res.AgentConnectionTimings = append(res.AgentConnectionTimings, codersdk.AgentConnectionTiming{ | ||
WorkspaceAgentID: agent.ID.String(), | ||
WorkspaceAgentName: agent.Name, | ||
StartedAt: agent.CreatedAt, | ||
Stage: "connect", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add constants for these stages, and share them across coderd & the frontend. |
||
EndedAt: agent.FirstConnectedAt.Time, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure. In this case, we should not return or display the connection stage in the chart 🤔 wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we show some pending state in this case? |
||
}) | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.