@parca/profile 0.16.411 → 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,10 @@
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
+
6
10
  ## [0.16.411](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.410...@parca/profile@0.16.411) (2024-07-15)
7
11
 
8
12
  **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,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileMetricsGraph/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,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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,12 +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, }) => {
80
+ const ProfileMetricsGraph = ({ queryClient, queryExpression, dirtyQueryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing = false, }) => {
81
81
  const profileType = useMemo(() => {
82
82
  return Query.parse(queryExpression).profileType();
83
83
  }, [queryExpression]);
84
+ const dirtyProfileType = useMemo(() => {
85
+ return Query.parse(dirtyQueryExpression).profileType();
86
+ }, [dirtyQueryExpression]);
84
87
  const { loading: labelNamesLoading, result: labelNamesResult } = useLabelNames(queryClient, profileType.toString() ?? '', from, to);
85
- const [sumBy, setSumBy] = useSumBy(profileType, labelNamesResult.response?.labelNames);
88
+ const [sumBy, setSumBy] = useSumBy(profileType, labelNamesLoading, labelNamesResult.response?.labelNames);
86
89
  const { isLoading: metricsGraphLoading, response, error, } = useQueryRange(queryClient, queryExpression, from, to, sumBy, labelNamesLoading);
87
90
  const { onError, perf, authenticationErrorMessage, isDarkMode } = useParcaContext();
88
91
  const { width, height, margin, heightStyle } = useMetricsGraphDimensions(comparing);
@@ -118,7 +121,7 @@ const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to,
118
121
  sampleUnit = Query.parse(queryExpression).profileType().sampleUnit;
119
122
  }
120
123
  }
121
- 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) => {
122
125
  onPointClick(timestamp, labels, queryExpression, duration);
123
126
  }, addLabelMatcher: addLabelMatcher, sampleUnit: sampleUnit, height: height, width: width, margin: margin })) : (_jsx(ProfileMetricsEmptyState, { message: "No data found. Try a different query." }))] }, "metrics-graph-loaded") }));
124
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,CAkEvC,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"}
@@ -10,16 +10,13 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
+ import { useCallback, useEffect, useMemo, useState } from 'react';
14
14
  import { useParcaContext, useURLState } from '@parca/components';
15
15
  export const DEFAULT_EMPTY_SUM_BY = [];
16
16
  const getDefaultSumBy = (profile, labels) => {
17
17
  if (profile === undefined || labels === undefined) {
18
18
  return undefined;
19
19
  }
20
- if (!profile.delta) {
21
- return [];
22
- }
23
20
  if (labels.includes('comm')) {
24
21
  return ['comm'];
25
22
  }
@@ -31,13 +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
- const previousProfileType = useRef(profileType);
41
37
  const userSelectedSumBy = useMemo(() => {
42
38
  if (userSelectedSumByParam?.length === 0) {
43
39
  return undefined;
@@ -64,17 +60,14 @@ export const useSumBy = (profileType, labels) => {
64
60
  }, [setUserSelectedSumByParam]);
65
61
  const [defaultSumBy, setDefaultSumBy] = useState(getDefaultSumBy(profileType, labels));
66
62
  useEffect(() => {
67
- setDefaultSumBy(getDefaultSumBy(profileType, labels));
68
- }, [profileType, labels]);
69
- useEffect(() => {
70
- if (profileType === undefined ||
71
- profileType.toString() === previousProfileType.current?.toString()) {
63
+ if (labelNamesLoading) {
72
64
  return;
73
65
  }
74
- // Reset user selected sumBy if profile type changes
75
- setUserSelectedSumBy(['']);
76
- previousProfileType.current = profileType;
77
- // eslint-disable-next-line react-hooks/exhaustive-deps
78
- }, [profileType]);
79
- 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];
80
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,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EvD,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;AAED,eAAO,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.411",
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": "8885ee532a664069e946e488f60b24cdac9c80f0"
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,
@@ -164,13 +166,21 @@ const ProfileMetricsGraph = ({
164
166
  return Query.parse(queryExpression).profileType();
165
167
  }, [queryExpression]);
166
168
 
169
+ const dirtyProfileType = useMemo(() => {
170
+ return Query.parse(dirtyQueryExpression).profileType();
171
+ }, [dirtyQueryExpression]);
172
+
167
173
  const {loading: labelNamesLoading, result: labelNamesResult} = useLabelNames(
168
174
  queryClient,
169
175
  profileType.toString() ?? '',
170
176
  from,
171
177
  to
172
178
  );
173
- const [sumBy, setSumBy] = useSumBy(profileType, labelNamesResult.response?.labelNames);
179
+ const [sumBy, setSumBy] = useSumBy(
180
+ profileType,
181
+ labelNamesLoading,
182
+ labelNamesResult.response?.labelNames
183
+ );
174
184
 
175
185
  const {
176
186
  isLoading: metricsGraphLoading,
@@ -233,11 +243,13 @@ const ProfileMetricsGraph = ({
233
243
  animate={{display: 'block', opacity: 1}}
234
244
  transition={{duration: 0.5}}
235
245
  >
236
- <Toolbar
237
- sumBy={sumBy}
238
- setSumBy={setSumBy}
239
- labels={labelNamesResult.response?.labelNames ?? []}
240
- />
246
+ {dirtyProfileType.delta ? (
247
+ <Toolbar
248
+ sumBy={sumBy}
249
+ setSumBy={setSumBy}
250
+ labels={labelNamesResult.response?.labelNames ?? []}
251
+ />
252
+ ) : null}
241
253
  {loading ? (
242
254
  <MetricsGraphSkeleton heightStyle={heightStyle} isDarkMode={isDarkMode} />
243
255
  ) : dataAvailable ? (
@@ -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, useEffect, useMemo, useRef, useState} from 'react';
14
+ import {useCallback, useEffect, useMemo, useState} from 'react';
15
15
 
16
16
  import {useParcaContext, useURLState} from '@parca/components';
17
17
  import {ProfileType} from '@parca/parser';
@@ -26,10 +26,6 @@ const getDefaultSumBy = (
26
26
  return undefined;
27
27
  }
28
28
 
29
- if (!profile.delta) {
30
- return [];
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();
@@ -54,7 +51,6 @@ export const useSumBy = (
54
51
  param: 'sum_by',
55
52
  navigateTo,
56
53
  });
57
- const previousProfileType = useRef<ProfileType | undefined>(profileType);
58
54
 
59
55
  const userSelectedSumBy = useMemo<string[] | undefined>(() => {
60
56
  if (userSelectedSumByParam?.length === 0) {
@@ -95,23 +91,17 @@ export const useSumBy = (
95
91
  );
96
92
 
97
93
  useEffect(() => {
98
- setDefaultSumBy(getDefaultSumBy(profileType, labels));
99
- }, [profileType, labels]);
100
-
101
- useEffect(() => {
102
- if (
103
- profileType === undefined ||
104
- profileType.toString() === previousProfileType.current?.toString()
105
- ) {
94
+ if (labelNamesLoading) {
106
95
  return;
107
96
  }
97
+ setDefaultSumBy(getDefaultSumBy(profileType, labels));
98
+ }, [profileType, labels, labelNamesLoading]);
108
99
 
109
- // Reset user selected sumBy if profile type changes
110
- setUserSelectedSumBy(['']);
111
- previousProfileType.current = profileType;
100
+ let sumBy = userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY;
112
101
 
113
- // eslint-disable-next-line react-hooks/exhaustive-deps
114
- }, [profileType]);
102
+ if (profileType?.delta !== true) {
103
+ sumBy = [];
104
+ }
115
105
 
116
- return [userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY, setUserSelectedSumBy];
106
+ return [sumBy, setUserSelectedSumBy];
117
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}