Skip to content

feat(site): add display for workspace timings #14773

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

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5268b1e
Add base components for the chart
BrunoQuaresma Sep 19, 2024
4d509f9
Improve spacing calc
BrunoQuaresma Sep 19, 2024
d48624b
Make bars clickable
BrunoQuaresma Sep 19, 2024
62152ce
Refactor code to allow multiple views
BrunoQuaresma Sep 20, 2024
fd84ed9
Add basic view and breadcrumbs
BrunoQuaresma Sep 23, 2024
f7f09ff
Add resource filtering
BrunoQuaresma Sep 23, 2024
2ffc75a
Find the right tick spacings
BrunoQuaresma Sep 23, 2024
a8372e1
Add colors to the bars
BrunoQuaresma Sep 23, 2024
f7c7488
Do not display Coder resource
BrunoQuaresma Sep 23, 2024
0868185
Add legends
BrunoQuaresma Sep 23, 2024
54d13c8
Handle empty search
BrunoQuaresma Sep 23, 2024
714e37b
Improve coder resource filter and adjust bar hover
BrunoQuaresma Sep 24, 2024
a2dd126
Only scroll the chart
BrunoQuaresma Sep 24, 2024
0b4747e
Add tooltip
BrunoQuaresma Sep 24, 2024
49d3a72
Refactor code and improve legends
BrunoQuaresma Sep 25, 2024
647635d
Adjust columns to fit the space
BrunoQuaresma Sep 25, 2024
6c742aa
Customize scroll
BrunoQuaresma Sep 25, 2024
9a8bb59
Add info tooltip
BrunoQuaresma Sep 25, 2024
4139151
Fix fmt
BrunoQuaresma Sep 25, 2024
bcff9c6
Fix nblock gen
BrunoQuaresma Sep 25, 2024
97b25d9
Fix key
BrunoQuaresma Sep 25, 2024
6d5c344
Debug on chromatic
BrunoQuaresma Sep 25, 2024
c4bd74e
Another debug image
BrunoQuaresma Sep 25, 2024
939ec9a
Try with useEffect
BrunoQuaresma Sep 25, 2024
49c69e0
Fix labels alignment
BrunoQuaresma Sep 26, 2024
61008a3
Increase border radius tooltip
BrunoQuaresma Sep 26, 2024
f969ef2
Add scroll mask
BrunoQuaresma Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Do not display Coder resource
  • Loading branch information
BrunoQuaresma committed Sep 23, 2024
commit f7c7488910186f30a614c09318deb0e45f1bf0c6
82 changes: 47 additions & 35 deletions site/src/modules/workspaces/WorkspaceTiming/Chart/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ export type Timing = Duration & {
* blocks.
*/
childrenCount: number;
/**
* Timings should always be included in duration and timeline calculations.
* However, some timings, such as those for Coder resources, may not be
* valuable or can be too spammy to present to the user. Therefore, we hide
* these specific timings from the visualization while still including them in
* the calculations.
*/
visible?: boolean;
color?: BarColor;
};

Expand Down Expand Up @@ -90,14 +98,16 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
<YAxisSection key={section.name}>
<YAxisCaption>{section.name}</YAxisCaption>
<YAxisLabels>
{section.timings.map((t) => (
<YAxisLabel
key={t.label}
id={`${encodeURIComponent(t.label)}-label`}
>
{t.label}
</YAxisLabel>
))}
{section.timings
.filter((t) => t.visible)
.map((t) => (
<YAxisLabel
key={t.label}
id={`${encodeURIComponent(t.label)}-label`}
>
{t.label}
</YAxisLabel>
))}
</YAxisLabels>
</YAxisSection>
);
Expand All @@ -110,33 +120,35 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
{data.map((section) => {
return (
<div key={section.name} css={styles.bars}>
{section.timings.map((t) => {
const offset =
t.startedAt.getTime() - totalDuration.startedAt.getTime();
const size = calcSize(durationTime(t));
return (
<Bar
color={t.color}
key={t.label}
x={calcSize(offset)}
width={size}
afterLabel={formatTime(durationTime(t))}
aria-labelledby={`${t.label}-label`}
ref={applyBarHeightToLabel}
disabled={t.childrenCount <= 1}
onClick={() => {
if (t.childrenCount <= 1) {
return;
}
onBarClick(t.label, section.name);
}}
>
{t.childrenCount > 1 && (
<TimingBlocks size={size} count={t.childrenCount} />
)}
</Bar>
);
})}
{section.timings
.filter((t) => t.visible)
.map((t) => {
const offset =
t.startedAt.getTime() - totalDuration.startedAt.getTime();
const size = calcSize(durationTime(t));
return (
<Bar
color={t.color}
key={t.label}
x={calcSize(offset)}
width={size}
afterLabel={formatTime(durationTime(t))}
aria-labelledby={`${t.label}-label`}
ref={applyBarHeightToLabel}
disabled={t.childrenCount <= 1}
onClick={() => {
if (t.childrenCount <= 1) {
return;
}
onBarClick(t.label, section.name);
}}
>
{t.childrenCount > 1 && (
<TimingBlocks size={size} count={t.childrenCount} />
)}
</Bar>
);
})}
</div>
);
})}
Expand Down
11 changes: 10 additions & 1 deletion site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const selectChartData = (
const stageTiming: Timing = {
label: stage,
childrenCount: durations.length,
visible: true,
...stageDuration,
};
return stageTiming;
Expand All @@ -132,10 +133,18 @@ export const selectChartData = (
t.stage === view.selectedStage && t.resource.includes(view.filter),
)
.map((t) => {
const isCoderResource =
t.resource.startsWith("data.coder") ||
t.resource.startsWith("module.coder");

return {
label: `${t.resource}.${t.action}`,
color: colorsByActions[t.action],
childrenCount: 0, // Resource timings don't have inner timings
// We don't want to display coder resources. Those will always show
// up as super short values and don't have much value.
visible: !isCoderResource,
// Resource timings don't have inner timings
childrenCount: 0,
...extractDuration(t),
} as Timing;
});
Expand Down