@parca/profile 0.19.94 → 0.19.102
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 +32 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +2 -0
- package/dist/ProfileSelector/MetricsGraphSection.d.ts +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +1 -1
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +1 -2
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +8 -0
- package/dist/SimpleMatchers/Select.d.ts.map +1 -1
- package/dist/SimpleMatchers/Select.js +3 -3
- package/dist/hooks/useLabels.d.ts.map +1 -1
- package/dist/hooks/useLabels.js +4 -1
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +53 -23
- package/dist/hooks/useQueryState.test.js +32 -22
- package/dist/useSumBy.d.ts +10 -2
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +30 -7
- package/package.json +15 -10
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +2 -0
- package/src/ProfileSelector/MetricsGraphSection.tsx +2 -2
- package/src/ProfileSelector/index.tsx +1 -5
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +8 -0
- package/src/SimpleMatchers/Select.tsx +3 -3
- package/src/hooks/useLabels.ts +5 -1
- package/src/hooks/useQueryState.test.tsx +41 -22
- package/src/hooks/useQueryState.ts +72 -31
- package/src/useSumBy.ts +58 -4
package/src/useSumBy.ts
CHANGED
|
@@ -52,6 +52,7 @@ export const useSumBySelection = (
|
|
|
52
52
|
profileType: ProfileType | undefined,
|
|
53
53
|
labelNamesLoading: boolean,
|
|
54
54
|
labels: string[] | undefined,
|
|
55
|
+
draftSumBy: string[] | undefined,
|
|
55
56
|
{
|
|
56
57
|
defaultValue,
|
|
57
58
|
}: {
|
|
@@ -100,9 +101,15 @@ export const useSumBySelection = (
|
|
|
100
101
|
const lastValidSumByRef = useRef<string[]>(DEFAULT_EMPTY_SUM_BY);
|
|
101
102
|
|
|
102
103
|
const sumBy = useMemo(() => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
if (labelNamesLoading) {
|
|
105
|
+
// For smoother UX, return draftSumBy first if available during loading
|
|
106
|
+
// as this must be recently computed with the draft time range labels.
|
|
107
|
+
if (draftSumBy !== undefined) {
|
|
108
|
+
return draftSumBy;
|
|
109
|
+
}
|
|
110
|
+
if (lastValidSumByRef.current == null) {
|
|
111
|
+
return lastValidSumByRef.current;
|
|
112
|
+
}
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
let result =
|
|
@@ -116,7 +123,7 @@ export const useSumBySelection = (
|
|
|
116
123
|
lastValidSumByRef.current = result;
|
|
117
124
|
|
|
118
125
|
return result;
|
|
119
|
-
}, [userSelectedSumBy, profileType, defaultSumBy, labelNamesLoading]);
|
|
126
|
+
}, [userSelectedSumBy, profileType, defaultSumBy, labelNamesLoading, draftSumBy]);
|
|
120
127
|
|
|
121
128
|
return [
|
|
122
129
|
sumBy,
|
|
@@ -187,11 +194,16 @@ export const useSumBy = (
|
|
|
187
194
|
queryClient: QueryServiceClient,
|
|
188
195
|
profileType: ProfileType | undefined,
|
|
189
196
|
timeRange: DateTimeRange,
|
|
197
|
+
draftProfileType: ProfileType | undefined,
|
|
198
|
+
draftTimeRange: DateTimeRange,
|
|
190
199
|
defaultValue?: string[]
|
|
191
200
|
): {
|
|
192
201
|
sumBy: string[] | undefined;
|
|
193
202
|
setSumBy: (sumBy: string[]) => void;
|
|
194
203
|
isLoading: boolean;
|
|
204
|
+
draftSumBy: string[] | undefined;
|
|
205
|
+
setDraftSumBy: (sumBy: string[] | undefined) => void;
|
|
206
|
+
isDraftSumByLoading: boolean;
|
|
195
207
|
} => {
|
|
196
208
|
const {loading: labelNamesLoading, result} = useLabelNames(
|
|
197
209
|
queryClient,
|
|
@@ -200,6 +212,13 @@ export const useSumBy = (
|
|
|
200
212
|
timeRange.getToMs()
|
|
201
213
|
);
|
|
202
214
|
|
|
215
|
+
const {draftSumBy, setDraftSumBy, isDraftSumByLoading} = useDraftSumBy(
|
|
216
|
+
queryClient,
|
|
217
|
+
draftProfileType,
|
|
218
|
+
draftTimeRange,
|
|
219
|
+
defaultValue
|
|
220
|
+
);
|
|
221
|
+
|
|
203
222
|
const labels = useMemo(() => {
|
|
204
223
|
return result.response?.labelNames === undefined ? [] : result.response.labelNames;
|
|
205
224
|
}, [result]);
|
|
@@ -208,6 +227,7 @@ export const useSumBy = (
|
|
|
208
227
|
profileType,
|
|
209
228
|
labelNamesLoading,
|
|
210
229
|
labels,
|
|
230
|
+
draftSumBy,
|
|
211
231
|
{defaultValue}
|
|
212
232
|
);
|
|
213
233
|
|
|
@@ -215,5 +235,39 @@ export const useSumBy = (
|
|
|
215
235
|
sumBy: sumBySelection,
|
|
216
236
|
setSumBy: setSumByInternal,
|
|
217
237
|
isLoading,
|
|
238
|
+
draftSumBy,
|
|
239
|
+
setDraftSumBy,
|
|
240
|
+
isDraftSumByLoading,
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export const useDraftSumBy = (
|
|
245
|
+
queryClient: QueryServiceClient,
|
|
246
|
+
profileType: ProfileType | undefined,
|
|
247
|
+
timeRange: DateTimeRange,
|
|
248
|
+
defaultValue?: string[]
|
|
249
|
+
): {
|
|
250
|
+
draftSumBy: string[] | undefined;
|
|
251
|
+
setDraftSumBy: (sumBy: string[] | undefined) => void;
|
|
252
|
+
isDraftSumByLoading: boolean;
|
|
253
|
+
} => {
|
|
254
|
+
const [draftSumBy, setDraftSumBy] = useState<string[] | undefined>(defaultValue);
|
|
255
|
+
const {loading: labelNamesLoading, result} = useLabelNames(
|
|
256
|
+
queryClient,
|
|
257
|
+
profileType?.toString() ?? '',
|
|
258
|
+
timeRange.getFromMs(),
|
|
259
|
+
timeRange.getToMs()
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
const labels = useMemo(() => {
|
|
263
|
+
return result.response?.labelNames === undefined ? [] : result.response.labelNames;
|
|
264
|
+
}, [result]);
|
|
265
|
+
|
|
266
|
+
const {defaultSumBy, isLoading} = useDefaultSumBy(profileType, labelNamesLoading, labels);
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
draftSumBy: draftSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY,
|
|
270
|
+
setDraftSumBy: setDraftSumBy,
|
|
271
|
+
isDraftSumByLoading: isLoading,
|
|
218
272
|
};
|
|
219
273
|
};
|