Skip to content

Commit f7c7488

Browse files
committed
Do not display Coder resource
1 parent a8372e1 commit f7c7488

File tree

2 files changed

+57
-36
lines changed

2 files changed

+57
-36
lines changed

site/src/modules/workspaces/WorkspaceTiming/Chart/Chart.tsx

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ export type Timing = Duration & {
3838
* blocks.
3939
*/
4040
childrenCount: number;
41+
/**
42+
* Timings should always be included in duration and timeline calculations.
43+
* However, some timings, such as those for Coder resources, may not be
44+
* valuable or can be too spammy to present to the user. Therefore, we hide
45+
* these specific timings from the visualization while still including them in
46+
* the calculations.
47+
*/
48+
visible?: boolean;
4149
color?: BarColor;
4250
};
4351

@@ -90,14 +98,16 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
9098
<YAxisSection key={section.name}>
9199
<YAxisCaption>{section.name}</YAxisCaption>
92100
<YAxisLabels>
93-
{section.timings.map((t) => (
94-
<YAxisLabel
95-
key={t.label}
96-
id={`${encodeURIComponent(t.label)}-label`}
97-
>
98-
{t.label}
99-
</YAxisLabel>
100-
))}
101+
{section.timings
102+
.filter((t) => t.visible)
103+
.map((t) => (
104+
<YAxisLabel
105+
key={t.label}
106+
id={`${encodeURIComponent(t.label)}-label`}
107+
>
108+
{t.label}
109+
</YAxisLabel>
110+
))}
101111
</YAxisLabels>
102112
</YAxisSection>
103113
);
@@ -110,33 +120,35 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
110120
{data.map((section) => {
111121
return (
112122
<div key={section.name} css={styles.bars}>
113-
{section.timings.map((t) => {
114-
const offset =
115-
t.startedAt.getTime() - totalDuration.startedAt.getTime();
116-
const size = calcSize(durationTime(t));
117-
return (
118-
<Bar
119-
color={t.color}
120-
key={t.label}
121-
x={calcSize(offset)}
122-
width={size}
123-
afterLabel={formatTime(durationTime(t))}
124-
aria-labelledby={`${t.label}-label`}
125-
ref={applyBarHeightToLabel}
126-
disabled={t.childrenCount <= 1}
127-
onClick={() => {
128-
if (t.childrenCount <= 1) {
129-
return;
130-
}
131-
onBarClick(t.label, section.name);
132-
}}
133-
>
134-
{t.childrenCount > 1 && (
135-
<TimingBlocks size={size} count={t.childrenCount} />
136-
)}
137-
</Bar>
138-
);
139-
})}
123+
{section.timings
124+
.filter((t) => t.visible)
125+
.map((t) => {
126+
const offset =
127+
t.startedAt.getTime() - totalDuration.startedAt.getTime();
128+
const size = calcSize(durationTime(t));
129+
return (
130+
<Bar
131+
color={t.color}
132+
key={t.label}
133+
x={calcSize(offset)}
134+
width={size}
135+
afterLabel={formatTime(durationTime(t))}
136+
aria-labelledby={`${t.label}-label`}
137+
ref={applyBarHeightToLabel}
138+
disabled={t.childrenCount <= 1}
139+
onClick={() => {
140+
if (t.childrenCount <= 1) {
141+
return;
142+
}
143+
onBarClick(t.label, section.name);
144+
}}
145+
>
146+
{t.childrenCount > 1 && (
147+
<TimingBlocks size={size} count={t.childrenCount} />
148+
)}
149+
</Bar>
150+
);
151+
})}
140152
</div>
141153
);
142154
})}

site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const selectChartData = (
112112
const stageTiming: Timing = {
113113
label: stage,
114114
childrenCount: durations.length,
115+
visible: true,
115116
...stageDuration,
116117
};
117118
return stageTiming;
@@ -132,10 +133,18 @@ export const selectChartData = (
132133
t.stage === view.selectedStage && t.resource.includes(view.filter),
133134
)
134135
.map((t) => {
136+
const isCoderResource =
137+
t.resource.startsWith("data.coder") ||
138+
t.resource.startsWith("module.coder");
139+
135140
return {
136141
label: `${t.resource}.${t.action}`,
137142
color: colorsByActions[t.action],
138-
childrenCount: 0, // Resource timings don't have inner timings
143+
// We don't want to display coder resources. Those will always show
144+
// up as super short values and don't have much value.
145+
visible: !isCoderResource,
146+
// Resource timings don't have inner timings
147+
childrenCount: 0,
139148
...extractDuration(t),
140149
} as Timing;
141150
});

0 commit comments

Comments
 (0)