Skip to content

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

Merged
merged 20 commits into from
Nov 1, 2024
Merged

Conversation

BrunoQuaresma
Copy link
Collaborator

Local preview:

Screenshot 2024-10-29 at 16 16 01

Close coder/internal#116

@BrunoQuaresma BrunoQuaresma self-assigned this Oct 29, 2024
@BrunoQuaresma
Copy link
Collaborator Author

@dannykopping I would appreciate a first round of review in the BE code and its usage.

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking good!

Added a few notes for things we can do to harden.

require.Empty(t, res.AgentScriptTimings)
})

//nolint:paralleltest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Howcome these are not in parallel?

All mentions of nolint should be followed with a reason like:

//nolint:paralleltest // Reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just following what we are already doing in other places:

All of them have the same reason based on this PR even thinking I had fixed it here.

Comment on lines 1033 to 1035
StartedAt: agent.CreatedAt,
Stage: "connect",
EndedAt: agent.FirstConnectedAt.Time,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first_connected_at is a nullable field; what do we do in this case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we show some pending state in this case?

@BrunoQuaresma BrunoQuaresma requested review from dannykopping, a team and aslilac and removed request for a team October 31, 2024 13:23
@BrunoQuaresma BrunoQuaresma marked this pull request as ready for review October 31, 2024 13:31
Comment on lines 260 to 262
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look a couple lines above, we already set this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why my vscode didn't recognize that

key={stage.name}
id={encodeURIComponent(stage.name)}
>
{stages.map((s) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I liked stage as a variable name here more. single letter variables names make me sad. :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working too much with Go lately 😆

Comment on lines 59 to 70
const stages = () => {
const agentStageLabels = Array.from(
new Set(
agentConnectionTimings.map((t) => `agent (${t.workspace_agent_name})`),
),
);
return [
...provisioningStages,
...agentStageLabels.flatMap((a) => agentStages(a)),
];
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why put this in a function that doesn't take any arguments and is only called once? if it's a performance concern, we should probably be using useMemo instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is true. I tried to improve readability by grouping related code to a function.

@@ -135,19 +158,18 @@ export const WorkspaceTimings: FC<WorkspaceTimingsProps> = ({
)}

{view.name === "detailed" &&
view.category.id === "workspaceBoot" && (
view.stage.section !== "provisioning" && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be put in a ternary with the condition above to reduce repeated conditions

Comment on lines 165 to 172
.map((t) => {
return {
range: extractRange(t),
range: toTimeRange(t),
name: t.display_name,
status: t.status,
exitCode: t.exit_code,
};
})}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be an implicit return

Suggested change
.map((t) => {
return {
range: extractRange(t),
range: toTimeRange(t),
name: t.display_name,
status: t.status,
exitCode: t.exit_code,
};
})}
.map((t) => ({
range: toTimeRange(t),
name: t.display_name,
status: t.status,
exitCode: t.exit_code,
}))

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a few minor nits & notes but I'm happy!

WorkspaceAgentID: agent.ID.String(),
WorkspaceAgentName: agent.Name,
StartedAt: agent.CreatedAt,
Stage: "connect",
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -1264,19 +1271,21 @@ func TestWorkspaceBuildTimings(t *testing.T) {
require.Empty(t, res.AgentScriptTimings)
})

//nolint:paralleltest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these marked as not parallel before? I'm concerned we're rolling back a change which was necessary to avoid some previous issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{
JobID: build.JobID,
})
agents := make([]database.WorkspaceAgent, 5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder about this one

Comment on lines 277 to 294
<TooltipShortDescription>
Time taken to establish an RPC connection with the control plane.
</TooltipShortDescription>
</>
),
},
},
{
name: "start",
label: "run startup scripts",
section,
tooltip: {
title: (
<>
<TooltipTitle>Run startup scripts</TooltipTitle>
<TooltipShortDescription>
Time taken to run each agent startup script.
</TooltipShortDescription>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should drop the "time taken" on these stages since the other sections' stages don't have them.

Suggested change
<TooltipShortDescription>
Time taken to establish an RPC connection with the control plane.
</TooltipShortDescription>
</>
),
},
},
{
name: "start",
label: "run startup scripts",
section,
tooltip: {
title: (
<>
<TooltipTitle>Run startup scripts</TooltipTitle>
<TooltipShortDescription>
Time taken to run each agent startup script.
</TooltipShortDescription>
<TooltipShortDescription>
Establish an RPC connection with the control plane.
</TooltipShortDescription>
</>
),
},
},
{
name: "start",
label: "run startup scripts",
section,
tooltip: {
title: (
<>
<TooltipTitle>Run startup scripts</TooltipTitle>
<TooltipShortDescription>
Execute each agent startup script.
</TooltipShortDescription>

@@ -11,6 +11,7 @@ const meta: Meta<typeof WorkspaceTimings> = {
defaultIsOpen: true,
provisionerTimings: WorkspaceTimingsResponse.provisioner_timings,
agentScriptTimings: WorkspaceTimingsResponse.agent_script_timings,
agentConnectionTimings: WorkspaceTimingsResponse.agent_connection_timings,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need some frontend tests for these timings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not specifically, if you see the stories, they are already represented there. If the component does not display for any reason, Chromatic will issue a warning.

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@BrunoQuaresma BrunoQuaresma merged commit e232aee into main Nov 1, 2024
30 checks passed
@BrunoQuaresma BrunoQuaresma deleted the bq/add-agent-timings branch November 1, 2024 16:29
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add agent registration timings
4 participants