@parca/profile 0.19.140 → 0.19.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/dist/GraphTooltipArrow/Content.js +224 -30
- package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
- package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/index.js +86 -56
- package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
- package/dist/MatchersInput/SuggestionItem.js +91 -12
- package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
- package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
- package/dist/MatchersInput/SuggestionsList.js +371 -157
- package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
- package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
- package/dist/MatchersInput/index.js +308 -115
- package/dist/MetricsCircle/index.js +39 -3
- package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
- package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
- package/dist/MetricsGraph/index.js +552 -203
- package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
- package/dist/MetricsGraph/utils/colorMapping.js +24 -17
- package/dist/MetricsSeries/index.js +70 -7
- package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
- package/dist/PreSelectedMatchers/index.js +249 -102
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
- package/dist/ProfileExplorer/index.js +183 -32
- package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
- package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/index.js +267 -129
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
- package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
- package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
- package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
- package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
- package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/index.js +324 -150
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +519 -258
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +727 -141
- package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
- package/dist/ProfileSource.js +230 -163
- package/dist/ProfileTypeSelector/index.js +214 -125
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
- package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
- package/dist/ProfileView/components/ColorStackLegend.js +185 -55
- package/dist/ProfileView/components/DashboardItems/index.js +87 -28
- package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
- package/dist/ProfileView/components/DiffLegend.js +172 -29
- package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
- package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
- package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
- package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
- package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
- package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
- package/dist/ProfileView/components/ShareButton/index.js +352 -62
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
- package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
- package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
- package/dist/ProfileView/components/ViewSelector/index.js +212 -86
- package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
- package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
- package/dist/ProfileView/components/VisualizationPanel.js +185 -8
- package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
- package/dist/ProfileView/context/DashboardContext.js +85 -29
- package/dist/ProfileView/context/ProfileViewContext.js +56 -15
- package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
- package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
- package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
- package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
- package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
- package/dist/ProfileView/index.js +383 -45
- package/dist/ProfileView/types/visualization.js +1 -13
- package/dist/ProfileView/utils/colorUtils.js +8 -7
- package/dist/ProfileViewWithData.d.ts.map +1 -1
- package/dist/ProfileViewWithData.js +332 -228
- package/dist/QueryControls/index.js +418 -47
- package/dist/Sandwich/components/CalleesSection.js +54 -4
- package/dist/Sandwich/components/CallersSection.js +97 -27
- package/dist/Sandwich/components/TableSection.js +77 -4
- package/dist/Sandwich/index.d.ts.map +1 -1
- package/dist/Sandwich/index.js +126 -14
- package/dist/Sandwich/utils/processRowData.js +48 -39
- package/dist/SelectWithRefresh/index.js +102 -28
- package/dist/SimpleMatchers/Select.js +520 -187
- package/dist/SimpleMatchers/index.js +590 -288
- package/dist/SourceView/Highlighter.js +230 -70
- package/dist/SourceView/LineNo.js +72 -17
- package/dist/SourceView/index.d.ts.map +1 -1
- package/dist/SourceView/index.js +178 -104
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
- package/dist/SourceView/useSelectedLineRange.js +99 -23
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.d.ts.map +1 -1
- package/dist/Table/MoreDropdown.js +122 -25
- package/dist/Table/TableContextMenu.d.ts.map +1 -1
- package/dist/Table/TableContextMenu.js +151 -137
- package/dist/Table/TableContextMenuWrapper.js +59 -14
- package/dist/Table/hooks/useColorManagement.js +58 -16
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +333 -169
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +222 -128
- package/dist/Table/utils/functions.js +169 -144
- package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
- package/dist/TimelineGuide/index.js +209 -16
- package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/dist/TopTable/index.d.ts.map +1 -1
- package/dist/TopTable/index.js +342 -123
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
- package/dist/hooks/useCompareModeMeta.js +158 -64
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +3 -3
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +373 -332
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -8
- package/dist/testdata/fg-diff.json +3750 -0
- package/dist/testdata/fg-simple.json +1879 -0
- package/dist/testdata/link_data.json +56 -0
- package/dist/testdata/tabular.json +30 -0
- package/dist/testdata/test_flamegraph.json +26846 -0
- package/dist/testdata/test_graph.json +53 -0
- package/dist/useDelayedLoader.js +32 -18
- package/dist/useGrpcQuery/index.js +71 -11
- package/dist/useHasProfileData.js +90 -12
- package/dist/useQuery.js +205 -64
- package/dist/useSumBy.d.ts +1 -1
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -10
- package/src/GraphTooltipArrow/index.tsx +3 -0
- package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
- package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
- package/src/MatchersInput/SuggestionsList.tsx +11 -10
- package/src/MatchersInput/index.tsx +1 -1
- package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
- package/src/PreSelectedMatchers/index.tsx +3 -0
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
- package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
- package/src/ProfileFlameChart/index.tsx +28 -21
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
- package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
- package/src/ProfileFlameGraph/index.tsx +9 -6
- package/src/ProfileMetricsGraph/index.tsx +8 -6
- package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
- package/src/ProfileSelector/index.tsx +61 -39
- package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
- package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
- package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
- package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
- package/src/ProfileView/components/Toolbars/index.tsx +3 -3
- package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/ProfileView/context/DashboardContext.tsx +6 -6
- package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
- package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
- package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
- package/src/ProfileViewWithData.tsx +35 -29
- package/src/Sandwich/index.tsx +3 -4
- package/src/SourceView/index.tsx +2 -4
- package/src/SourceView/useSelectedLineRange.ts +19 -34
- package/src/Table/MoreDropdown.tsx +11 -9
- package/src/Table/TableContextMenu.tsx +13 -10
- package/src/Table/hooks/useTableConfiguration.tsx +11 -16
- package/src/Table/index.tsx +21 -12
- package/src/TopTable/index.tsx +4 -3
- package/src/hooks/useCompareModeMeta.ts +91 -61
- package/src/hooks/useQueryState.test.tsx +345 -275
- package/src/hooks/useQueryState.ts +118 -136
- package/src/index.tsx +15 -16
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +15 -21
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/urlParsers.d.ts +0 -18
- package/dist/hooks/urlParsers.d.ts.map +0 -1
- package/dist/hooks/urlParsers.js +0 -32
- package/dist/hooks/useColorBy.d.ts +0 -5
- package/dist/hooks/useColorBy.d.ts.map +0 -1
- package/dist/hooks/useColorBy.js +0 -26
- package/dist/hooks/useDashboardItems.d.ts +0 -5
- package/dist/hooks/useDashboardItems.d.ts.map +0 -1
- package/dist/hooks/useDashboardItems.js +0 -27
- package/dist/hooks/useQueryState.test.js +0 -868
- package/src/hooks/urlParsers.ts +0 -38
- package/src/hooks/useColorBy.ts +0 -42
- package/src/hooks/useDashboardItems.ts +0 -46
|
@@ -13,9 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import {useCallback, useEffect, useMemo, useState} from 'react';
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
import {DateTimeRange, useParcaContext} from '@parca/components';
|
|
16
|
+
import {DateTimeRange, useParcaContext, useURLState, useURLStateBatch} from '@parca/components';
|
|
19
17
|
import {Query} from '@parca/parser';
|
|
20
18
|
|
|
21
19
|
import {QuerySelection} from '../ProfileSelector';
|
|
@@ -23,7 +21,6 @@ import {ProfileSelection, ProfileSelectionFromParams, ProfileSource} from '../Pr
|
|
|
23
21
|
import {useResetFlameGraphState} from '../ProfileView/hooks/useResetFlameGraphState';
|
|
24
22
|
import {useResetStateOnProfileTypeChange} from '../ProfileView/hooks/useResetStateOnProfileTypeChange';
|
|
25
23
|
import {DEFAULT_EMPTY_SUM_BY, sumByToParam, useSumBy, useSumByFromParams} from '../useSumBy';
|
|
26
|
-
import {commaArrayParam, stringParam} from './urlParsers';
|
|
27
24
|
|
|
28
25
|
interface UseQueryStateOptions {
|
|
29
26
|
suffix?: '_a' | '_b'; // For comparison mode
|
|
@@ -70,9 +67,9 @@ interface UseQueryStateReturn {
|
|
|
70
67
|
// parsed query
|
|
71
68
|
parsedQuery: Query | null;
|
|
72
69
|
|
|
73
|
-
setExpressionParam: (value: string |
|
|
74
|
-
setSumByParam: (value: string |
|
|
75
|
-
setGroupByParam: (value: string[] |
|
|
70
|
+
setExpressionParam: (value: string | undefined) => void;
|
|
71
|
+
setSumByParam: (value: string | undefined) => void;
|
|
72
|
+
setGroupByParam: (value: string[] | undefined) => void;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryStateReturn => {
|
|
@@ -87,65 +84,41 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
87
84
|
onProfileTypeChange,
|
|
88
85
|
} = options;
|
|
89
86
|
|
|
87
|
+
const batchUpdates = useURLStateBatch();
|
|
90
88
|
const resetFlameGraphState = useResetFlameGraphState();
|
|
91
89
|
const resetStateOnProfileTypeChange = useResetStateOnProfileTypeChange();
|
|
92
90
|
|
|
93
|
-
// URL state hooks with appropriate suffixes
|
|
94
|
-
const [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
from: stringParam,
|
|
98
|
-
to: stringParam,
|
|
99
|
-
time_selection: stringParam,
|
|
100
|
-
sum_by: stringParam,
|
|
101
|
-
merge_from: stringParam,
|
|
102
|
-
merge_to: stringParam,
|
|
103
|
-
selection: stringParam,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
history: 'replace',
|
|
107
|
-
urlKeys: {
|
|
108
|
-
expression: `expression${suffix}`,
|
|
109
|
-
from: `from${suffix}`,
|
|
110
|
-
to: `to${suffix}`,
|
|
111
|
-
time_selection: `time_selection${suffix}`,
|
|
112
|
-
sum_by: `sum_by${suffix}`,
|
|
113
|
-
merge_from: `merge_from${suffix}`,
|
|
114
|
-
merge_to: `merge_to${suffix}`,
|
|
115
|
-
selection: `selection${suffix}`,
|
|
116
|
-
},
|
|
117
|
-
}
|
|
118
|
-
);
|
|
91
|
+
// URL state hooks with appropriate suffixes
|
|
92
|
+
const [expression, setExpressionState] = useURLState<string>(`expression${suffix}`, {
|
|
93
|
+
defaultValue: defaultExpression,
|
|
94
|
+
});
|
|
119
95
|
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const timeSelection = queryParams.time_selection ?? defaultTimeSelection;
|
|
124
|
-
const sumByParam = queryParams.sum_by;
|
|
125
|
-
const mergeFrom = queryParams.merge_from;
|
|
126
|
-
const mergeTo = queryParams.merge_to;
|
|
127
|
-
const selectionParam = queryParams.selection;
|
|
128
|
-
|
|
129
|
-
// Individual setters for direct access
|
|
130
|
-
const setExpressionState = useCallback(
|
|
131
|
-
(val: string | null) => void setQueryParams({expression: val}),
|
|
132
|
-
[setQueryParams]
|
|
133
|
-
);
|
|
134
|
-
const setSumByParam = useCallback(
|
|
135
|
-
(val: string | null) => void setQueryParams({sum_by: val}),
|
|
136
|
-
[setQueryParams]
|
|
137
|
-
);
|
|
96
|
+
const [from, setFromState] = useURLState<string>(`from${suffix}`, {
|
|
97
|
+
defaultValue: defaultFrom?.toString(),
|
|
98
|
+
});
|
|
138
99
|
|
|
139
|
-
const [,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
100
|
+
const [to, setToState] = useURLState<string>(`to${suffix}`, {
|
|
101
|
+
defaultValue: defaultTo?.toString(),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const [timeSelection, setTimeSelectionState] = useURLState<string>(`time_selection${suffix}`, {
|
|
105
|
+
defaultValue: defaultTimeSelection,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const [sumByParam, setSumByParam] = useURLState<string>(`sum_by${suffix}`);
|
|
109
|
+
|
|
110
|
+
const [, setGroupByParam] = useURLState<string>('group_by', {
|
|
111
|
+
alwaysReturnArray: true,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const [mergeFrom, setMergeFromState] = useURLState<string>(`merge_from${suffix}`);
|
|
115
|
+
const [mergeTo, setMergeToState] = useURLState<string>(`merge_to${suffix}`);
|
|
116
|
+
|
|
117
|
+
// ProfileSelection URL state hooks - reuses merge_from/merge_to but adds selection
|
|
118
|
+
const [selectionParam, setSelectionParam] = useURLState<string>(`selection${suffix}`);
|
|
146
119
|
|
|
147
120
|
// Parse sumBy from URL parameter format
|
|
148
|
-
const sumBy = useSumByFromParams(sumByParam
|
|
121
|
+
const sumBy = useSumByFromParams(sumByParam);
|
|
149
122
|
|
|
150
123
|
// Draft state management
|
|
151
124
|
const [draftExpression, setDraftExpression] = useState<string>(expression ?? defaultExpression);
|
|
@@ -230,8 +203,8 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
230
203
|
// Sync computed sumBy to URL if URL doesn't already have a value
|
|
231
204
|
// to ensure the shared URL can always pick it up.
|
|
232
205
|
useEffect(() => {
|
|
233
|
-
if (sumByParam ===
|
|
234
|
-
|
|
206
|
+
if (sumByParam === undefined && computedSumByFromURL !== undefined && !sumBySelectionLoading) {
|
|
207
|
+
setSumByParam(sumByToParam(computedSumByFromURL));
|
|
235
208
|
}
|
|
236
209
|
}, [sumByParam, computedSumByFromURL, sumBySelectionLoading, setSumByParam]);
|
|
237
210
|
|
|
@@ -239,8 +212,8 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
239
212
|
const querySelection: QuerySelection = useMemo(() => {
|
|
240
213
|
const range = DateTimeRange.fromRangeKey(
|
|
241
214
|
timeSelection ?? defaultTimeSelection,
|
|
242
|
-
from
|
|
243
|
-
to
|
|
215
|
+
from !== undefined && from !== '' ? parseInt(from) : defaultFrom,
|
|
216
|
+
to !== undefined && to !== '' ? parseInt(to) : defaultTo
|
|
244
217
|
);
|
|
245
218
|
|
|
246
219
|
return {
|
|
@@ -249,7 +222,7 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
249
222
|
to: range.getToMs(),
|
|
250
223
|
timeSelection: range.getRangeKey(),
|
|
251
224
|
sumBy: computedSumByFromURL,
|
|
252
|
-
...(mergeFrom
|
|
225
|
+
...(mergeFrom !== undefined && mergeFrom !== '' && mergeTo !== undefined && mergeTo !== ''
|
|
253
226
|
? {mergeFrom, mergeTo}
|
|
254
227
|
: {}),
|
|
255
228
|
};
|
|
@@ -302,11 +275,7 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
302
275
|
|
|
303
276
|
// Compute ProfileSelection from URL params
|
|
304
277
|
const profileSelection = useMemo<ProfileSelection | null>(() => {
|
|
305
|
-
return ProfileSelectionFromParams(
|
|
306
|
-
mergeFrom ?? undefined,
|
|
307
|
-
mergeTo ?? undefined,
|
|
308
|
-
selectionParam ?? undefined
|
|
309
|
-
);
|
|
278
|
+
return ProfileSelectionFromParams(mergeFrom, mergeTo, selectionParam);
|
|
310
279
|
}, [mergeFrom, mergeTo, selectionParam]);
|
|
311
280
|
|
|
312
281
|
// Compute ProfileSource from ProfileSelection
|
|
@@ -324,77 +293,83 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
324
293
|
refreshedTimeRange?: {from: number; to: number; timeSelection: string},
|
|
325
294
|
expression?: string
|
|
326
295
|
) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
// Update draft state with new expression if provided
|
|
331
|
-
if (expression !== undefined) {
|
|
332
|
-
setDraftExpression(expression);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Calculate the actual from/to values from draftSelection if not provided
|
|
336
|
-
const calculatedFrom = draftSelection.from.toString();
|
|
337
|
-
const calculatedTo = draftSelection.to.toString();
|
|
296
|
+
batchUpdates(() => {
|
|
297
|
+
// Use provided expression or current draft expression
|
|
298
|
+
const finalExpression = expression ?? draftExpression;
|
|
338
299
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const finalTimeSelection = refreshedTimeRange?.timeSelection ?? draftTimeSelection;
|
|
344
|
-
|
|
345
|
-
// Update draft state with refreshed time range if provided
|
|
346
|
-
if (refreshedTimeRange?.from !== undefined) {
|
|
347
|
-
setDraftFrom(finalFrom);
|
|
348
|
-
}
|
|
349
|
-
if (refreshedTimeRange?.to !== undefined) {
|
|
350
|
-
setDraftTo(finalTo);
|
|
351
|
-
}
|
|
352
|
-
if (refreshedTimeRange?.timeSelection !== undefined) {
|
|
353
|
-
setDraftTimeSelection(finalTimeSelection);
|
|
354
|
-
}
|
|
300
|
+
// Update draft state with new expression if provided
|
|
301
|
+
if (expression !== undefined) {
|
|
302
|
+
setDraftExpression(expression);
|
|
303
|
+
}
|
|
355
304
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
305
|
+
// Calculate the actual from/to values from draftSelection if not provided
|
|
306
|
+
const calculatedFrom = draftSelection.from.toString();
|
|
307
|
+
const calculatedTo = draftSelection.to.toString();
|
|
359
308
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
309
|
+
const finalFrom =
|
|
310
|
+
refreshedTimeRange?.from?.toString() ?? (draftFrom !== '' ? draftFrom : calculatedFrom);
|
|
311
|
+
const finalTo =
|
|
312
|
+
refreshedTimeRange?.to?.toString() ?? (draftTo !== '' ? draftTo : calculatedTo);
|
|
313
|
+
const finalTimeSelection = refreshedTimeRange?.timeSelection ?? draftTimeSelection;
|
|
364
314
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
315
|
+
// Update draft state with refreshed time range if provided
|
|
316
|
+
if (refreshedTimeRange?.from !== undefined) {
|
|
317
|
+
setDraftFrom(finalFrom);
|
|
318
|
+
}
|
|
319
|
+
if (refreshedTimeRange?.to !== undefined) {
|
|
320
|
+
setDraftTo(finalTo);
|
|
321
|
+
}
|
|
322
|
+
if (refreshedTimeRange?.timeSelection !== undefined) {
|
|
323
|
+
setDraftTimeSelection(finalTimeSelection);
|
|
324
|
+
}
|
|
370
325
|
|
|
371
|
-
|
|
372
|
-
|
|
326
|
+
setExpressionState(finalExpression);
|
|
327
|
+
setFromState(finalFrom);
|
|
328
|
+
setToState(finalTo);
|
|
329
|
+
setTimeSelectionState(finalTimeSelection);
|
|
330
|
+
|
|
331
|
+
// Auto-calculate merge parameters for delta profiles
|
|
332
|
+
// Parse the final expression to check if it's a delta profile
|
|
333
|
+
const finalQuery = Query.parse(finalExpression);
|
|
334
|
+
const isDelta = finalQuery.profileType().delta;
|
|
335
|
+
if (isDelta) {
|
|
336
|
+
setSumByParam(sumByToParam(draftSumBy));
|
|
337
|
+
} else {
|
|
338
|
+
setSumByParam(DEFAULT_EMPTY_SUM_BY);
|
|
373
339
|
}
|
|
374
|
-
}
|
|
375
340
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
341
|
+
if (isDelta && finalFrom !== '' && finalTo !== '') {
|
|
342
|
+
const fromMs = parseInt(finalFrom);
|
|
343
|
+
const toMs = parseInt(finalTo);
|
|
344
|
+
setMergeFromState((BigInt(fromMs) * 1_000_000n).toString());
|
|
345
|
+
setMergeToState((BigInt(toMs) * 1_000_000n).toString());
|
|
346
|
+
|
|
347
|
+
// Auto-select the time range for delta profiles (but not in compare mode)
|
|
348
|
+
// This applies both on initial load AND when Search is clicked
|
|
349
|
+
// The selection will use the final expression and the updated time range
|
|
350
|
+
if (!comparing) {
|
|
351
|
+
setSelectionParam(finalExpression);
|
|
352
|
+
} else {
|
|
353
|
+
setSelectionParam(undefined);
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
setMergeFromState(undefined);
|
|
357
|
+
setMergeToState(undefined);
|
|
358
|
+
// Clear ProfileSelection for non-delta profiles
|
|
359
|
+
setSelectionParam(undefined);
|
|
360
|
+
}
|
|
361
|
+
resetFlameGraphState();
|
|
362
|
+
if (
|
|
363
|
+
draftProfileType.toString() !==
|
|
364
|
+
Query.parse(querySelection.expression).profileType().toString()
|
|
365
|
+
) {
|
|
366
|
+
resetStateOnProfileTypeChange();
|
|
367
|
+
onProfileTypeChange?.();
|
|
368
|
+
}
|
|
386
369
|
});
|
|
387
|
-
|
|
388
|
-
resetFlameGraphState();
|
|
389
|
-
if (
|
|
390
|
-
draftProfileType.toString() !==
|
|
391
|
-
Query.parse(querySelection.expression).profileType().toString()
|
|
392
|
-
) {
|
|
393
|
-
resetStateOnProfileTypeChange();
|
|
394
|
-
onProfileTypeChange?.();
|
|
395
|
-
}
|
|
396
370
|
},
|
|
397
371
|
[
|
|
372
|
+
batchUpdates,
|
|
398
373
|
draftExpression,
|
|
399
374
|
draftFrom,
|
|
400
375
|
draftTo,
|
|
@@ -403,7 +378,14 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
403
378
|
draftSelection.from,
|
|
404
379
|
draftSelection.to,
|
|
405
380
|
comparing,
|
|
406
|
-
|
|
381
|
+
setExpressionState,
|
|
382
|
+
setFromState,
|
|
383
|
+
setToState,
|
|
384
|
+
setTimeSelectionState,
|
|
385
|
+
setSumByParam,
|
|
386
|
+
setMergeFromState,
|
|
387
|
+
setMergeToState,
|
|
388
|
+
setSelectionParam,
|
|
407
389
|
resetFlameGraphState,
|
|
408
390
|
resetStateOnProfileTypeChange,
|
|
409
391
|
onProfileTypeChange,
|
|
@@ -452,13 +434,13 @@ export const useQueryState = (options: UseQueryStateOptions = {}): UseQueryState
|
|
|
452
434
|
// Set ProfileSelection (auto-commits to URL immediately)
|
|
453
435
|
const setProfileSelection = useCallback(
|
|
454
436
|
(mergeFrom: bigint, mergeTo: bigint, query: Query) => {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
437
|
+
batchUpdates(() => {
|
|
438
|
+
setSelectionParam(query.toString());
|
|
439
|
+
setMergeFromState(mergeFrom.toString());
|
|
440
|
+
setMergeToState(mergeTo.toString());
|
|
459
441
|
});
|
|
460
442
|
},
|
|
461
|
-
[
|
|
443
|
+
[batchUpdates, setSelectionParam, setMergeFromState, setMergeToState]
|
|
462
444
|
);
|
|
463
445
|
|
|
464
446
|
const draftParsedQuery = useMemo(() => {
|
package/src/index.tsx
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
import {CompressionType, setCompressionCodec} from '@uwdata/flechette';
|
|
15
15
|
import * as lz4 from 'lz4js';
|
|
16
16
|
|
|
17
|
+
import type {ParamPreferences} from '@parca/components';
|
|
18
|
+
|
|
17
19
|
import MatchersInput from './MatchersInput';
|
|
18
20
|
import MetricsGraph, {type ContextMenuItemOrSubmenu, type Series} from './MetricsGraph';
|
|
19
21
|
import ProfileExplorer from './ProfileExplorer';
|
|
@@ -58,23 +60,20 @@ export {QueryControls} from './QueryControls';
|
|
|
58
60
|
export {default as ProfileFilters} from './ProfileView/components/ProfileFilters';
|
|
59
61
|
export {useProfileFiltersUrlState} from './ProfileView/components/ProfileFilters/useProfileFiltersUrlState';
|
|
60
62
|
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
jsonParser,
|
|
74
|
-
} from './hooks/urlParsers';
|
|
63
|
+
export const DEFAULT_PROFILE_EXPLORER_PARAM_VALUES: ParamPreferences = {
|
|
64
|
+
dashboard_items: {
|
|
65
|
+
defaultValue: 'flamegraph',
|
|
66
|
+
splitOnCommas: true, // This param should split on commas for array values
|
|
67
|
+
},
|
|
68
|
+
group_by: {
|
|
69
|
+
splitOnCommas: true,
|
|
70
|
+
},
|
|
71
|
+
flamechart_dimension: {
|
|
72
|
+
splitOnCommas: true,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
75
|
|
|
76
|
-
export {
|
|
77
|
-
export {useColorBy} from './hooks/useColorBy';
|
|
76
|
+
export {useProfileTypes} from './ProfileSelector';
|
|
78
77
|
|
|
79
78
|
export {
|
|
80
79
|
ProfileExplorer,
|
package/src/useDelayedLoader.ts
CHANGED
|
@@ -18,20 +18,20 @@ interface DelayedLoaderOptions {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const useDelayedLoader = (isLoading = false, options?: DelayedLoaderOptions): boolean => {
|
|
21
|
+
'use no memo';
|
|
21
22
|
const {delay = 500} = options ?? {};
|
|
22
23
|
const [isLoaderVisible, setIsLoaderVisible] = useState<boolean>(false);
|
|
23
24
|
useEffect(() => {
|
|
24
|
-
|
|
25
|
-
if
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
if (!isLoading) return;
|
|
26
|
+
// if the request takes longer than half a second, show the loading icon
|
|
27
|
+
const showLoaderTimeout = setTimeout(() => {
|
|
28
|
+
setIsLoaderVisible(true);
|
|
29
|
+
}, delay);
|
|
30
|
+
return () => {
|
|
31
|
+
clearTimeout(showLoaderTimeout);
|
|
31
32
|
setIsLoaderVisible(false);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}, [isLoading, isLoaderVisible, delay]);
|
|
33
|
+
};
|
|
34
|
+
}, [isLoading, delay]);
|
|
35
35
|
|
|
36
36
|
return isLoaderVisible;
|
|
37
37
|
};
|
package/src/useSumBy.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
|
|
14
|
-
import {useCallback,
|
|
14
|
+
import {useCallback, useMemo, useState} from 'react';
|
|
15
15
|
|
|
16
16
|
import {QueryServiceClient} from '@parca/client';
|
|
17
17
|
import {DateTimeRange} from '@parca/components';
|
|
@@ -70,14 +70,19 @@ export const useSumBySelection = (
|
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
// Update userSelectedSumBy when defaultValue changes (e.g., during navigation)
|
|
73
|
-
|
|
73
|
+
const [prevProfileType, setPrevProfileType] = useState(profileType);
|
|
74
|
+
const [prevDefaultValue, setPrevDefaultValue] = useState(defaultValue);
|
|
75
|
+
|
|
76
|
+
if (prevProfileType !== profileType || prevDefaultValue !== defaultValue) {
|
|
77
|
+
setPrevProfileType(profileType);
|
|
78
|
+
setPrevDefaultValue(defaultValue);
|
|
74
79
|
if (profileType != null && defaultValue !== undefined) {
|
|
75
80
|
setUserSelectedSumBy(prev => ({
|
|
76
81
|
...prev,
|
|
77
82
|
[profileType.toString()]: defaultValue,
|
|
78
83
|
}));
|
|
79
84
|
}
|
|
80
|
-
}
|
|
85
|
+
}
|
|
81
86
|
|
|
82
87
|
const setSumBy = useCallback(
|
|
83
88
|
(sumBy: string[]) => {
|
|
@@ -97,19 +102,11 @@ export const useSumBySelection = (
|
|
|
97
102
|
|
|
98
103
|
const {defaultSumBy} = useDefaultSumBy(profileType, labelNamesLoading, labels);
|
|
99
104
|
|
|
100
|
-
// Store the last valid sumBy value to return during loading
|
|
101
|
-
const lastValidSumByRef = useRef<string[]>(DEFAULT_EMPTY_SUM_BY);
|
|
102
|
-
|
|
103
105
|
const sumBy = useMemo(() => {
|
|
104
|
-
if
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return draftSumBy;
|
|
109
|
-
}
|
|
110
|
-
if (lastValidSumByRef.current == null) {
|
|
111
|
-
return lastValidSumByRef.current;
|
|
112
|
-
}
|
|
106
|
+
// For smoother UX, return draftSumBy first if available during loading
|
|
107
|
+
// as this must be recently computed with the draft time range labels.
|
|
108
|
+
if (labelNamesLoading && draftSumBy !== undefined) {
|
|
109
|
+
return draftSumBy;
|
|
113
110
|
}
|
|
114
111
|
|
|
115
112
|
// Prefer non-empty URL default over auto-computed default to avoid a
|
|
@@ -125,9 +122,6 @@ export const useSumBySelection = (
|
|
|
125
122
|
result = DEFAULT_EMPTY_SUM_BY;
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
// Store the computed value for next loading state
|
|
129
|
-
lastValidSumByRef.current = result;
|
|
130
|
-
|
|
131
125
|
return result;
|
|
132
126
|
}, [userSelectedSumBy, profileType, defaultSumBy, labelNamesLoading, draftSumBy, defaultValue]);
|
|
133
127
|
|
|
@@ -183,16 +177,16 @@ export const useSumByFromParams = (param: string | string[] | undefined): string
|
|
|
183
177
|
return sumBy;
|
|
184
178
|
};
|
|
185
179
|
|
|
186
|
-
export const sumByToParam = (sumBy: string[] | undefined): string |
|
|
180
|
+
export const sumByToParam = (sumBy: string[] | undefined): string | string[] | undefined => {
|
|
187
181
|
if (sumBy === undefined) {
|
|
188
|
-
return
|
|
182
|
+
return undefined;
|
|
189
183
|
}
|
|
190
184
|
|
|
191
185
|
if (sumBy.length === 0) {
|
|
192
186
|
return '__none__';
|
|
193
187
|
}
|
|
194
188
|
|
|
195
|
-
return sumBy
|
|
189
|
+
return sumBy;
|
|
196
190
|
};
|
|
197
191
|
|
|
198
192
|
// Combined hook that handles all sumBy logic: fetching labels, computing defaults, and managing selection
|