@parca/profile 0.16.410 → 0.16.412

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.16.412](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.411...@parca/profile@0.16.412) (2024-07-16)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.16.411](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.410...@parca/profile@0.16.411) (2024-07-15)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
6
14
  ## [0.16.410](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.409...@parca/profile@0.16.410) (2024-07-11)
7
15
 
8
16
  **Note:** Version bump only for package @parca/profile
@@ -9,6 +9,7 @@ export declare const ProfileMetricsEmptyState: ({ message }: ProfileMetricsEmpty
9
9
  interface ProfileMetricsGraphProps {
10
10
  queryClient: QueryServiceClient;
11
11
  queryExpression: string;
12
+ dirtyQueryExpression: string;
12
13
  profile: ProfileSelection | null;
13
14
  from: number;
14
15
  to: number;
@@ -29,6 +30,6 @@ export interface IQueryRangeState {
29
30
  error: RpcError | null;
30
31
  }
31
32
  export declare const useQueryRange: (client: QueryServiceClient, queryExpression: string, start: number, end: number, sumBy?: string[], skip?: boolean) => IQueryRangeState;
32
- declare const ProfileMetricsGraph: ({ queryClient, queryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing, }: ProfileMetricsGraphProps) => JSX.Element;
33
+ declare const ProfileMetricsGraph: ({ queryClient, queryExpression, dirtyQueryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing, }: ProfileMetricsGraphProps) => JSX.Element;
33
34
  export default ProfileMetricsGraph;
34
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3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AM,EACvB,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CACxB;AAYD,eAAO,MAAM,aAAa,WAChB,kBAAkB,mBACT,MAAM,SAChB,MAAM,OACR,MAAM,UACJ,MAAM,EAAE,qBAEd,gBA+CF,CAAC;AAEF,QAAA,MAAM,mBAAmB,uIAWtB,wBAAwB,KAAG,GAAG,CAAC,OAsHjC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -77,9 +77,15 @@ export const useQueryRange = (client, queryExpression, start, end, sumBy = DEFAU
77
77
  });
78
78
  return { isLoading, error: error, response: data ?? null };
79
79
  };
80
- const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing = false, }) => {
81
- const { loading: labelNamesLoading, result: labelNamesResult } = useLabelNames(queryClient, profile?.ProfileSource()?.ProfileType()?.toString() ?? '', from, to);
82
- const [sumBy, setSumBy] = useSumBy(profile?.ProfileSource()?.ProfileType(), labelNamesResult.response?.labelNames);
80
+ const ProfileMetricsGraph = ({ queryClient, queryExpression, dirtyQueryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing = false, }) => {
81
+ const profileType = useMemo(() => {
82
+ return Query.parse(queryExpression).profileType();
83
+ }, [queryExpression]);
84
+ const dirtyProfileType = useMemo(() => {
85
+ return Query.parse(dirtyQueryExpression).profileType();
86
+ }, [dirtyQueryExpression]);
87
+ const { loading: labelNamesLoading, result: labelNamesResult } = useLabelNames(queryClient, profileType.toString() ?? '', from, to);
88
+ const [sumBy, setSumBy] = useSumBy(profileType, labelNamesLoading, labelNamesResult.response?.labelNames);
83
89
  const { isLoading: metricsGraphLoading, response, error, } = useQueryRange(queryClient, queryExpression, from, to, sumBy, labelNamesLoading);
84
90
  const { onError, perf, authenticationErrorMessage, isDarkMode } = useParcaContext();
85
91
  const { width, height, margin, heightStyle } = useMetricsGraphDimensions(comparing);
@@ -115,7 +121,7 @@ const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to,
115
121
  sampleUnit = Query.parse(queryExpression).profileType().sampleUnit;
116
122
  }
117
123
  }
118
- return (_jsx(AnimatePresence, { children: _jsxs(motion.div, { className: "h-full w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: [_jsx(Toolbar, { sumBy: sumBy, setSumBy: setSumBy, labels: labelNamesResult.response?.labelNames ?? [] }), loading ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode })) : dataAvailable ? (_jsx(MetricsGraph, { data: series, from: from, to: to, profile: profile, setTimeRange: setTimeRange, onSampleClick: (timestamp, _value, labels, duration) => {
124
+ return (_jsx(AnimatePresence, { children: _jsxs(motion.div, { className: "h-full w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: [dirtyProfileType.delta ? (_jsx(Toolbar, { sumBy: sumBy, setSumBy: setSumBy, labels: labelNamesResult.response?.labelNames ?? [] })) : null, loading ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode })) : dataAvailable ? (_jsx(MetricsGraph, { data: series, from: from, to: to, profile: profile, setTimeRange: setTimeRange, onSampleClick: (timestamp, _value, labels, duration) => {
119
125
  onPointClick(timestamp, labels, queryExpression, duration);
120
126
  }, addLabelMatcher: addLabelMatcher, sampleUnit: sampleUnit, height: height, width: width, margin: margin })) : (_jsx(ProfileMetricsEmptyState, { message: "No data found. Try a different query." }))] }, "metrics-graph-loaded") }));
121
127
  };
@@ -1,4 +1,4 @@
1
1
  import { ProfileType } from '@parca/parser';
2
2
  export declare const DEFAULT_EMPTY_SUM_BY: string[];
3
- export declare const useSumBy: (profileType: ProfileType | undefined, labels: string[] | undefined) => [string[], (labels: string[]) => void];
3
+ export declare const useSumBy: (profileType: ProfileType | undefined, labelNamesLoading: boolean, labels: string[] | undefined) => [string[], (labels: string[]) => void];
4
4
  //# sourceMappingURL=useSumBy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSumBy.d.ts","sourceRoot":"","sources":["../../src/ProfileMetricsGraph/useSumBy.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAO,CAAC;AA6BjD,eAAO,MAAM,QAAQ,gBACN,WAAW,GAAG,SAAS,UAC5B,MAAM,EAAE,GAAG,SAAS,KAC3B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CA+EvC,CAAC"}
1
+ {"version":3,"file":"useSumBy.d.ts","sourceRoot":"","sources":["../../src/ProfileMetricsGraph/useSumBy.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,eAAO,MAAM,oBAAoB,EAAE,MAAM,EAAO,CAAC;AAyBjD,eAAO,MAAM,QAAQ,gBACN,WAAW,GAAG,SAAS,qBACjB,OAAO,UAClB,MAAM,EAAE,GAAG,SAAS,KAC3B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CA2DvC,CAAC"}
@@ -17,9 +17,6 @@ const getDefaultSumBy = (profile, labels) => {
17
17
  if (profile === undefined || labels === undefined) {
18
18
  return undefined;
19
19
  }
20
- if (!profile.delta) {
21
- return undefined;
22
- }
23
20
  if (labels.includes('comm')) {
24
21
  return ['comm'];
25
22
  }
@@ -31,14 +28,12 @@ const getDefaultSumBy = (profile, labels) => {
31
28
  }
32
29
  return undefined;
33
30
  };
34
- export const useSumBy = (profileType, labels) => {
31
+ export const useSumBy = (profileType, labelNamesLoading, labels) => {
35
32
  const { navigateTo } = useParcaContext();
36
33
  const [userSelectedSumByParam, setUserSelectedSumByParam] = useURLState({
37
34
  param: 'sum_by',
38
35
  navigateTo,
39
36
  });
40
- console.log('labels', labels);
41
- console.log('userSelectedSumByParam', userSelectedSumByParam);
42
37
  const userSelectedSumBy = useMemo(() => {
43
38
  if (userSelectedSumByParam?.length === 0) {
44
39
  return undefined;
@@ -51,7 +46,6 @@ export const useSumBy = (profileType, labels) => {
51
46
  }
52
47
  return userSelectedSumByParam;
53
48
  }, [userSelectedSumByParam]);
54
- console.log('userSelectedSumBy', userSelectedSumBy);
55
49
  const setUserSelectedSumBy = useCallback((sumBy) => {
56
50
  if (sumBy.length === 0) {
57
51
  setUserSelectedSumByParam('__none__');
@@ -66,25 +60,14 @@ export const useSumBy = (profileType, labels) => {
66
60
  }, [setUserSelectedSumByParam]);
67
61
  const [defaultSumBy, setDefaultSumBy] = useState(getDefaultSumBy(profileType, labels));
68
62
  useEffect(() => {
69
- setDefaultSumBy(getDefaultSumBy(profileType, labels));
70
- }, [profileType, labels]);
71
- useEffect(() => {
72
- if (profileType === undefined || labels === undefined) {
63
+ if (labelNamesLoading) {
73
64
  return;
74
65
  }
75
- if (userSelectedSumBy !== undefined && userSelectedSumBy.length === 0) {
76
- // User has explicitly selected no sumBy, so don't reset it
77
- return;
78
- }
79
- if (userSelectedSumBy !== undefined && userSelectedSumBy.length > 0) {
80
- // If any of the user selected sumBy is present in the labels, then don't reset it
81
- if (userSelectedSumBy.some(sumBy => labels?.includes(sumBy))) {
82
- return;
83
- }
84
- }
85
- // Reset user selected sumBy if profile type changes
86
- setUserSelectedSumBy(['']);
87
- // eslint-disable-next-line react-hooks/exhaustive-deps
88
- }, [profileType, labels]);
89
- return [userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY, setUserSelectedSumBy];
66
+ setDefaultSumBy(getDefaultSumBy(profileType, labels));
67
+ }, [profileType, labels, labelNamesLoading]);
68
+ let sumBy = userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY;
69
+ if (profileType?.delta !== true) {
70
+ sumBy = [];
71
+ }
72
+ return [sumBy, setUserSelectedSumBy];
90
73
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAQ,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAY9E,OAAO,EAAC,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAyB,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAO5D,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,oBAAoB;IAC5B,WAAW,EAAE,kBAAkB,CAAC;IAChC,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAClD,WAAW,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC1C,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AA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MAAM,eAAe,WAAY,kBAAkB,KAAG,mBAkB5D,CAAC;AAEF,QAAA,MAAM,eAAe,6IAUlB,oBAAoB,KAAG,GAAG,CAAC,OA4P7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -149,7 +149,7 @@ const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQue
149
149
  }, id: "h-matcher-search-button", children: "Search" }) })] }), _jsx("div", { children: comparing && _jsx(IconButton, { onClick: () => closeProfile(), icon: _jsx(CloseIcon, {}) }) })] }), _jsx("div", { className: "rounded bg-white shadow dark:border-gray-500 dark:bg-gray-700", children: _jsx("div", { style: { height: heightStyle }, children: querySelection.expression !== undefined &&
150
150
  querySelection.expression.length > 0 &&
151
151
  querySelection.from !== undefined &&
152
- querySelection.to !== undefined ? (_jsx("div", { className: "p-2", children: _jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, setTimeRange: (range) => {
152
+ querySelection.to !== undefined ? (_jsx("div", { className: "p-2", children: _jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, dirtyQueryExpression: queryExpressionString, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, setTimeRange: (range) => {
153
153
  const from = range.getFromMs();
154
154
  const to = range.getToMs();
155
155
  let mergedProfileParams = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.410",
3
+ "version": "0.16.412",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@headlessui/react": "^1.7.19",
@@ -73,5 +73,5 @@
73
73
  "access": "public",
74
74
  "registry": "https://registry.npmjs.org/"
75
75
  },
76
- "gitHead": "7fc4b0d3e5a29c4a79f8762185ec8b874dfdef2c"
76
+ "gitHead": "ba668d046e2eea3514961fac022c19b21ff16412"
77
77
  }
@@ -61,6 +61,7 @@ export const ProfileMetricsEmptyState = ({message}: ProfileMetricsEmptyStateProp
61
61
  interface ProfileMetricsGraphProps {
62
62
  queryClient: QueryServiceClient;
63
63
  queryExpression: string;
64
+ dirtyQueryExpression: string;
64
65
  profile: ProfileSelection | null;
65
66
  from: number;
66
67
  to: number;
@@ -152,6 +153,7 @@ export const useQueryRange = (
152
153
  const ProfileMetricsGraph = ({
153
154
  queryClient,
154
155
  queryExpression,
156
+ dirtyQueryExpression,
155
157
  profile,
156
158
  from,
157
159
  to,
@@ -160,14 +162,23 @@ const ProfileMetricsGraph = ({
160
162
  onPointClick,
161
163
  comparing = false,
162
164
  }: ProfileMetricsGraphProps): JSX.Element => {
165
+ const profileType = useMemo(() => {
166
+ return Query.parse(queryExpression).profileType();
167
+ }, [queryExpression]);
168
+
169
+ const dirtyProfileType = useMemo(() => {
170
+ return Query.parse(dirtyQueryExpression).profileType();
171
+ }, [dirtyQueryExpression]);
172
+
163
173
  const {loading: labelNamesLoading, result: labelNamesResult} = useLabelNames(
164
174
  queryClient,
165
- profile?.ProfileSource()?.ProfileType()?.toString() ?? '',
175
+ profileType.toString() ?? '',
166
176
  from,
167
177
  to
168
178
  );
169
179
  const [sumBy, setSumBy] = useSumBy(
170
- profile?.ProfileSource()?.ProfileType(),
180
+ profileType,
181
+ labelNamesLoading,
171
182
  labelNamesResult.response?.labelNames
172
183
  );
173
184
 
@@ -232,11 +243,13 @@ const ProfileMetricsGraph = ({
232
243
  animate={{display: 'block', opacity: 1}}
233
244
  transition={{duration: 0.5}}
234
245
  >
235
- <Toolbar
236
- sumBy={sumBy}
237
- setSumBy={setSumBy}
238
- labels={labelNamesResult.response?.labelNames ?? []}
239
- />
246
+ {dirtyProfileType.delta ? (
247
+ <Toolbar
248
+ sumBy={sumBy}
249
+ setSumBy={setSumBy}
250
+ labels={labelNamesResult.response?.labelNames ?? []}
251
+ />
252
+ ) : null}
240
253
  {loading ? (
241
254
  <MetricsGraphSkeleton heightStyle={heightStyle} isDarkMode={isDarkMode} />
242
255
  ) : dataAvailable ? (
@@ -26,10 +26,6 @@ const getDefaultSumBy = (
26
26
  return undefined;
27
27
  }
28
28
 
29
- if (!profile.delta) {
30
- return undefined;
31
- }
32
-
33
29
  if (labels.includes('comm')) {
34
30
  return ['comm'];
35
31
  }
@@ -47,6 +43,7 @@ const getDefaultSumBy = (
47
43
 
48
44
  export const useSumBy = (
49
45
  profileType: ProfileType | undefined,
46
+ labelNamesLoading: boolean,
50
47
  labels: string[] | undefined
51
48
  ): [string[], (labels: string[]) => void] => {
52
49
  const {navigateTo} = useParcaContext();
@@ -55,10 +52,6 @@ export const useSumBy = (
55
52
  navigateTo,
56
53
  });
57
54
 
58
- console.log('labels', labels);
59
-
60
- console.log('userSelectedSumByParam', userSelectedSumByParam);
61
-
62
55
  const userSelectedSumBy = useMemo<string[] | undefined>(() => {
63
56
  if (userSelectedSumByParam?.length === 0) {
64
57
  return undefined;
@@ -75,8 +68,6 @@ export const useSumBy = (
75
68
  return userSelectedSumByParam;
76
69
  }, [userSelectedSumByParam]);
77
70
 
78
- console.log('userSelectedSumBy', userSelectedSumBy);
79
-
80
71
  const setUserSelectedSumBy = useCallback(
81
72
  (sumBy: string[]) => {
82
73
  if (sumBy.length === 0) {
@@ -100,31 +91,17 @@ export const useSumBy = (
100
91
  );
101
92
 
102
93
  useEffect(() => {
103
- setDefaultSumBy(getDefaultSumBy(profileType, labels));
104
- }, [profileType, labels]);
105
-
106
- useEffect(() => {
107
- if (profileType === undefined || labels === undefined) {
94
+ if (labelNamesLoading) {
108
95
  return;
109
96
  }
97
+ setDefaultSumBy(getDefaultSumBy(profileType, labels));
98
+ }, [profileType, labels, labelNamesLoading]);
110
99
 
111
- if (userSelectedSumBy !== undefined && userSelectedSumBy.length === 0) {
112
- // User has explicitly selected no sumBy, so don't reset it
113
- return;
114
- }
115
-
116
- if (userSelectedSumBy !== undefined && userSelectedSumBy.length > 0) {
117
- // If any of the user selected sumBy is present in the labels, then don't reset it
118
- if (userSelectedSumBy.some(sumBy => labels?.includes(sumBy))) {
119
- return;
120
- }
121
- }
122
-
123
- // Reset user selected sumBy if profile type changes
124
- setUserSelectedSumBy(['']);
100
+ let sumBy = userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY;
125
101
 
126
- // eslint-disable-next-line react-hooks/exhaustive-deps
127
- }, [profileType, labels]);
102
+ if (profileType?.delta !== true) {
103
+ sumBy = [];
104
+ }
128
105
 
129
- return [userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY, setUserSelectedSumBy];
106
+ return [sumBy, setUserSelectedSumBy];
130
107
  };
@@ -284,6 +284,7 @@ const ProfileSelector = ({
284
284
  <ProfileMetricsGraph
285
285
  queryClient={queryClient}
286
286
  queryExpression={querySelection.expression}
287
+ dirtyQueryExpression={queryExpressionString}
287
288
  from={querySelection.from}
288
289
  to={querySelection.to}
289
290
  profile={profileSelection}