Skip to content

Commit ccaef9e

Browse files
authored
ui: Configurable metrics graph height and increase truncation limit (#6204)
Also includes the increasing the truncation count for the `file` in the graph tooltip
1 parent cebb4dc commit ccaef9e

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

ui/packages/shared/components/src/ParcaContext/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface AdditionalMetricsGraphProps {
4949
timeRange: DateTimeRange;
5050
onTimeRangeChange: (range: DateTimeRange) => void;
5151
commitTimeRange: () => void;
52+
selectTimeRange: (range: DateTimeRange) => void;
5253
}
5354

5455
interface Props {

ui/packages/shared/profile/src/GraphTooltipArrow/Content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const TooltipMetaInfo = ({table, row}: {table: Table; row: number}): React.JSX.E
175175
) : (
176176
<div className="flex gap-4">
177177
<div className="whitespace-nowrap text-left">
178-
<ExpandOnHover value={file} displayValue={truncateStringReverse(file, 30)} />
178+
<ExpandOnHover value={file} displayValue={truncateStringReverse(file, 50)} />
179179
</div>
180180
</div>
181181
)}

ui/packages/shared/profile/src/MetricsGraph/useMetricsGraphDimensions.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ export const useMetricsGraphDimensions = (
4646
width = width / 2 - 32;
4747
}
4848
const height = isMini ? MINI_VARIANT_HEIGHT : Math.min(width / 2.5, maxHeight);
49-
const heightStyle = `min(${maxHeight + margin}px, ${
50-
comparing
51-
? profileExplorer.metricsGraph.maxHeightStyle.compareMode
52-
: profileExplorer.metricsGraph.maxHeightStyle.default
53-
})`;
49+
const heightStyle = isMini
50+
? `${MINI_VARIANT_HEIGHT + margin}px`
51+
: `min(${maxHeight + margin}px, ${
52+
comparing
53+
? profileExplorer.metricsGraph.maxHeightStyle.compareMode
54+
: profileExplorer.metricsGraph.maxHeightStyle.default
55+
})`;
5456
return {
5557
width,
5658
height,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ const ProfileMetricsGraph = ({
225225
queryExpression === ''
226226
);
227227
const {onError, perf, authenticationErrorMessage, isDarkMode, timezone} = useParcaContext();
228-
const {width, height, margin, heightStyle} = useMetricsGraphDimensions(comparing);
228+
const isGpuProfileType = queryExpression.includes(':cuda:');
229+
const {width, height, margin, heightStyle} = useMetricsGraphDimensions(
230+
comparing,
231+
isGpuProfileType
232+
);
229233
const [showAllSeriesForResponse, setShowAllSeriesForResponse] = useState<typeof response | null>(
230234
null
231235
);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import {DateTimeRange, useURLStateBatch} from '@parca/components';
1818
import {Query} from '@parca/parser';
1919

2020
import {ProfileSelection} from '..';
21+
import {useMetricsGraphDimensions} from '../MetricsGraph/useMetricsGraphDimensions';
2122
import ProfileMetricsGraph, {ProfileMetricsEmptyState} from '../ProfileMetricsGraph';
2223
import {useResetStateOnSeriesChange} from '../ProfileView/hooks/useResetStateOnSeriesChange';
2324
import {QuerySelection} from './index';
2425

2526
interface MetricsGraphSectionProps {
2627
showMetricsGraph: boolean;
2728
setDisplayHideMetricsGraphButton?: (show: boolean) => void;
28-
heightStyle: string;
2929
querySelection: QuerySelection;
3030
profileSelection: ProfileSelection | null;
3131
comparing: boolean;
@@ -50,7 +50,6 @@ interface MetricsGraphSectionProps {
5050
export function MetricsGraphSection({
5151
showMetricsGraph,
5252
setDisplayHideMetricsGraphButton,
53-
heightStyle,
5453
querySelection,
5554
profileSelection,
5655
comparing,
@@ -69,6 +68,8 @@ export function MetricsGraphSection({
6968
}: MetricsGraphSectionProps): JSX.Element {
7069
const resetStateOnSeriesChange = useResetStateOnSeriesChange();
7170
const batchUpdates = useURLStateBatch();
71+
const isGpuProfileType = querySelection.expression.includes(':cuda:');
72+
const {heightStyle} = useMetricsGraphDimensions(comparing, isGpuProfileType);
7273
const handleTimeRangeChange = (range: DateTimeRange): void => {
7374
const from = range.getFromMs();
7475
const to = range.getToMs();

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {Query} from '@parca/parser';
2929
import {TEST_IDS, testId} from '@parca/test-utils';
3030
import {millisToProtoTimestamp, type NavigateFunction} from '@parca/utilities';
3131

32-
import {useMetricsGraphDimensions} from '../MetricsGraph/useMetricsGraphDimensions';
3332
import {
3433
ProfileFilter,
3534
useProfileFilters,
@@ -118,7 +117,6 @@ const ProfileSelector = ({
118117
suffix,
119118
onSearchHook,
120119
}: ProfileSelectorProps): JSX.Element => {
121-
const {heightStyle} = useMetricsGraphDimensions(comparing, false);
122120
const {viewComponent, additionalMetricsGraph} = useParcaContext();
123121
const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');
124122
const batchUpdates = useURLStateBatch();
@@ -298,6 +296,13 @@ const ProfileSelector = ({
298296
timeRange: timeRangeSelection,
299297
onTimeRangeChange: handleTimeRangeChange,
300298
commitTimeRange: () => setQueryExpression(true),
299+
selectTimeRange: (range: DateTimeRange) => {
300+
commitDraft({
301+
from: range.getFromMs(),
302+
to: range.getToMs(),
303+
timeSelection: range.getRangeKey(),
304+
});
305+
},
301306
})}
302307
<LabelsQueryProvider
303308
setMatchersString={setMatchersString}
@@ -356,7 +361,6 @@ const ProfileSelector = ({
356361
<MetricsGraphSection
357362
showMetricsGraph={showMetricsGraph}
358363
setDisplayHideMetricsGraphButton={setDisplayHideMetricsGraphButton}
359-
heightStyle={heightStyle}
360364
querySelection={querySelection}
361365
profileSelection={profileSelection}
362366
comparing={comparing}

0 commit comments

Comments
 (0)