Skip to content

Commit 0cb2d6b

Browse files
ui: Utilization metrics series selection fixes (#6055)
* Utilization metrics series selection fixes * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 3d0be0e commit 0cb2d6b

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

ui/packages/shared/profile/src/MetricsGraph/UtilizationMetrics/Throughput.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface NetworkSeries {
3838
values: number[][];
3939
labelset: string;
4040
isReceive?: boolean;
41+
isSelected?: boolean;
4142
}
4243

4344
interface CommonProps {
@@ -52,7 +53,7 @@ interface CommonProps {
5253
from: number;
5354
to: number;
5455
selectedSeries?: Array<{key: string; value: string}>;
55-
onSeriesClick?: (seriesIndex: number) => void;
56+
onSeriesClick?: (name: string, seriesIndex: number) => void;
5657
}
5758

5859
type RawAreaChartProps = CommonProps & {
@@ -186,6 +187,7 @@ function transformToSeries(data: MetricSeries[], isReceive = false): NetworkSeri
186187
}, []),
187188
labelset: metric.map(m => `${m.name}=${m.value}`).join(','),
188189
isReceive,
190+
isSelected: s.isSelected,
189191
});
190192
}
191193
return agg;
@@ -223,6 +225,7 @@ function transformNetworkSeriesToSeries(
223225
timestamp,
224226
value,
225227
]),
228+
highlighted: networkSeries.isSelected ?? false,
226229
};
227230
});
228231
}
@@ -259,7 +262,7 @@ const RawAreaChart = ({
259262
setTimeRange={setTimeRange}
260263
onSampleClick={closestPoint => {
261264
if (onSeriesClick != null) {
262-
onSeriesClick(closestPoint.seriesIndex);
265+
onSeriesClick(humanReadableName, closestPoint.seriesIndex);
263266
}
264267
}}
265268
yAxisLabel={humanReadableName}

ui/packages/shared/profile/src/ProfileSelector/MetricsGraphSection.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface MetricsGraphSectionProps {
4747
data: UtilizationMetricsType[];
4848
}>;
4949
utilizationMetricsLoading?: boolean;
50-
onUtilizationSeriesSelect?: (seriesIndex: number) => void;
50+
onUtilizationSeriesSelect?: (name: string, seriesIndex: number) => void;
5151
}
5252

5353
export function MetricsGraphSection({
@@ -161,6 +161,12 @@ export function MetricsGraphSection({
161161
metric.name === 'gpu_pcie_throughput_transmit_bytes' ||
162162
metric.name === 'gpu_pcie_throughput_receive_bytes'
163163
);
164+
const transmitData =
165+
throughputMetrics.find(metric => metric.name === 'gpu_pcie_throughput_transmit_bytes')
166+
?.data ?? [];
167+
const receiveData =
168+
throughputMetrics.find(metric => metric.name === 'gpu_pcie_throughput_receive_bytes')?.data ??
169+
[];
164170

165171
if (utilizationMetrics.length === 0) {
166172
return <></>;
@@ -187,7 +193,7 @@ export function MetricsGraphSection({
187193
onSeriesClick={seriesIndex => {
188194
// For generic UtilizationMetrics, just pass the series index
189195
if (onUtilizationSeriesSelect != null) {
190-
onUtilizationSeriesSelect(seriesIndex);
196+
onUtilizationSeriesSelect(name, seriesIndex);
191197
}
192198
}}
193199
/>
@@ -197,14 +203,8 @@ export function MetricsGraphSection({
197203
})}
198204
{throughputMetrics.length > 0 && (
199205
<AreaChart
200-
transmitData={
201-
throughputMetrics.find(metric => metric.name === 'gpu_pcie_throughput_transmit_bytes')
202-
?.data ?? []
203-
}
204-
receiveData={
205-
throughputMetrics.find(metric => metric.name === 'gpu_pcie_throughput_receive_bytes')
206-
?.data ?? []
207-
}
206+
transmitData={transmitData}
207+
receiveData={receiveData}
208208
addLabelMatcher={addLabelMatcher}
209209
setTimeRange={handleTimeRangeChange}
210210
name={throughputMetrics[0].name}
@@ -213,7 +213,17 @@ export function MetricsGraphSection({
213213
to={querySelection.to}
214214
utilizationMetricsLoading={utilizationMetricsLoading}
215215
selectedSeries={undefined}
216-
onSeriesClick={onUtilizationSeriesSelect}
216+
onSeriesClick={(name, seriesIndex) => {
217+
// For throughput metrics, just pass the series index
218+
if (onUtilizationSeriesSelect != null) {
219+
let name = 'gpu_pcie_throughput_transmit_bytes';
220+
if (seriesIndex > transmitData.length - 1) {
221+
name = 'gpu_pcie_throughput_receive_bytes';
222+
seriesIndex -= transmitData.length;
223+
}
224+
onUtilizationSeriesSelect(name, seriesIndex);
225+
}
226+
}}
217227
/>
218228
)}
219229
</div>

ui/packages/shared/profile/src/ProfileSelector/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ interface ProfileSelectorProps extends ProfileSelectorFeatures {
9292
}>;
9393
utilizationMetricsLoading?: boolean;
9494
utilizationLabels?: UtilizationLabels;
95-
onUtilizationSeriesSelect?: (seriesIndex: number) => void;
95+
onUtilizationSeriesSelect?: (name: string, seriesIndex: number) => void;
9696
onSearchHook?: () => void;
9797
}
9898

0 commit comments

Comments
 (0)