@parca/profile 0.16.410 → 0.16.411

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.411](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.410...@parca/profile@0.16.411) (2024-07-15)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## [0.16.410](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.409...@parca/profile@0.16.410) (2024-07-11)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileMetricsGraph/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAGlD,OAAO,EAAW,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAY,MAAM,eAAe,CAAC;AACjG,OAAO,EACL,aAAa,EAKd,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAyB,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAQ5D,UAAU,6BAA6B;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAaD,eAAO,MAAM,wBAAwB,gBAAe,6BAA6B,KAAG,GAAG,CAAC,OAMvF,CAAC;AAEF,UAAU,wBAAwB;IAChC,WAAW,EAAE,kBAAkB,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,CACf,MAAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QA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AE,gBAAgB,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,eAAe,EAAE,CACf,MAAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,KACvE,IAAI,CAAC;IACV,YAAY,EAAE,CACZ,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,KAAK,EAAE,EACf,eAAe,EAAE,MAAM,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,iHAUtB,wBAAwB,KAAG,GAAG,CAAC,OA4GjC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -78,8 +78,11 @@ export const useQueryRange = (client, queryExpression, start, end, sumBy = DEFAU
78
78
  return { isLoading, error: error, response: data ?? null };
79
79
  };
80
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);
81
+ const profileType = useMemo(() => {
82
+ return Query.parse(queryExpression).profileType();
83
+ }, [queryExpression]);
84
+ const { loading: labelNamesLoading, result: labelNamesResult } = useLabelNames(queryClient, profileType.toString() ?? '', from, to);
85
+ const [sumBy, setSumBy] = useSumBy(profileType, labelNamesResult.response?.labelNames);
83
86
  const { isLoading: metricsGraphLoading, response, error, } = useQueryRange(queryClient, queryExpression, from, to, sumBy, labelNamesLoading);
84
87
  const { onError, perf, authenticationErrorMessage, isDarkMode } = useParcaContext();
85
88
  const { width, height, margin, heightStyle } = useMetricsGraphDimensions(comparing);
@@ -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;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"}
@@ -10,7 +10,7 @@
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, useState } from 'react';
13
+ import { useCallback, useEffect, useMemo, useRef, 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) => {
@@ -18,7 +18,7 @@ const getDefaultSumBy = (profile, labels) => {
18
18
  return undefined;
19
19
  }
20
20
  if (!profile.delta) {
21
- return undefined;
21
+ return [];
22
22
  }
23
23
  if (labels.includes('comm')) {
24
24
  return ['comm'];
@@ -37,8 +37,7 @@ export const useSumBy = (profileType, labels) => {
37
37
  param: 'sum_by',
38
38
  navigateTo,
39
39
  });
40
- console.log('labels', labels);
41
- console.log('userSelectedSumByParam', userSelectedSumByParam);
40
+ const previousProfileType = useRef(profileType);
42
41
  const userSelectedSumBy = useMemo(() => {
43
42
  if (userSelectedSumByParam?.length === 0) {
44
43
  return undefined;
@@ -51,7 +50,6 @@ export const useSumBy = (profileType, labels) => {
51
50
  }
52
51
  return userSelectedSumByParam;
53
52
  }, [userSelectedSumByParam]);
54
- console.log('userSelectedSumBy', userSelectedSumBy);
55
53
  const setUserSelectedSumBy = useCallback((sumBy) => {
56
54
  if (sumBy.length === 0) {
57
55
  setUserSelectedSumByParam('__none__');
@@ -69,22 +67,14 @@ export const useSumBy = (profileType, labels) => {
69
67
  setDefaultSumBy(getDefaultSumBy(profileType, labels));
70
68
  }, [profileType, labels]);
71
69
  useEffect(() => {
72
- if (profileType === undefined || labels === undefined) {
73
- return;
74
- }
75
- if (userSelectedSumBy !== undefined && userSelectedSumBy.length === 0) {
76
- // User has explicitly selected no sumBy, so don't reset it
70
+ if (profileType === undefined ||
71
+ profileType.toString() === previousProfileType.current?.toString()) {
77
72
  return;
78
73
  }
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
74
  // Reset user selected sumBy if profile type changes
86
75
  setUserSelectedSumBy(['']);
76
+ previousProfileType.current = profileType;
87
77
  // eslint-disable-next-line react-hooks/exhaustive-deps
88
- }, [profileType, labels]);
78
+ }, [profileType]);
89
79
  return [userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY, setUserSelectedSumBy];
90
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.410",
3
+ "version": "0.16.411",
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": "8885ee532a664069e946e488f60b24cdac9c80f0"
77
77
  }
@@ -160,16 +160,17 @@ const ProfileMetricsGraph = ({
160
160
  onPointClick,
161
161
  comparing = false,
162
162
  }: ProfileMetricsGraphProps): JSX.Element => {
163
+ const profileType = useMemo(() => {
164
+ return Query.parse(queryExpression).profileType();
165
+ }, [queryExpression]);
166
+
163
167
  const {loading: labelNamesLoading, result: labelNamesResult} = useLabelNames(
164
168
  queryClient,
165
- profile?.ProfileSource()?.ProfileType()?.toString() ?? '',
169
+ profileType.toString() ?? '',
166
170
  from,
167
171
  to
168
172
  );
169
- const [sumBy, setSumBy] = useSumBy(
170
- profile?.ProfileSource()?.ProfileType(),
171
- labelNamesResult.response?.labelNames
172
- );
173
+ const [sumBy, setSumBy] = useSumBy(profileType, labelNamesResult.response?.labelNames);
173
174
 
174
175
  const {
175
176
  isLoading: metricsGraphLoading,
@@ -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, useState} from 'react';
14
+ import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
15
15
 
16
16
  import {useParcaContext, useURLState} from '@parca/components';
17
17
  import {ProfileType} from '@parca/parser';
@@ -27,7 +27,7 @@ const getDefaultSumBy = (
27
27
  }
28
28
 
29
29
  if (!profile.delta) {
30
- return undefined;
30
+ return [];
31
31
  }
32
32
 
33
33
  if (labels.includes('comm')) {
@@ -54,10 +54,7 @@ export const useSumBy = (
54
54
  param: 'sum_by',
55
55
  navigateTo,
56
56
  });
57
-
58
- console.log('labels', labels);
59
-
60
- console.log('userSelectedSumByParam', userSelectedSumByParam);
57
+ const previousProfileType = useRef<ProfileType | undefined>(profileType);
61
58
 
62
59
  const userSelectedSumBy = useMemo<string[] | undefined>(() => {
63
60
  if (userSelectedSumByParam?.length === 0) {
@@ -75,8 +72,6 @@ export const useSumBy = (
75
72
  return userSelectedSumByParam;
76
73
  }, [userSelectedSumByParam]);
77
74
 
78
- console.log('userSelectedSumBy', userSelectedSumBy);
79
-
80
75
  const setUserSelectedSumBy = useCallback(
81
76
  (sumBy: string[]) => {
82
77
  if (sumBy.length === 0) {
@@ -104,27 +99,19 @@ export const useSumBy = (
104
99
  }, [profileType, labels]);
105
100
 
106
101
  useEffect(() => {
107
- if (profileType === undefined || labels === undefined) {
108
- return;
109
- }
110
-
111
- if (userSelectedSumBy !== undefined && userSelectedSumBy.length === 0) {
112
- // User has explicitly selected no sumBy, so don't reset it
102
+ if (
103
+ profileType === undefined ||
104
+ profileType.toString() === previousProfileType.current?.toString()
105
+ ) {
113
106
  return;
114
107
  }
115
108
 
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
109
  // Reset user selected sumBy if profile type changes
124
110
  setUserSelectedSumBy(['']);
111
+ previousProfileType.current = profileType;
125
112
 
126
113
  // eslint-disable-next-line react-hooks/exhaustive-deps
127
- }, [profileType, labels]);
114
+ }, [profileType]);
128
115
 
129
116
  return [userSelectedSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY, setUserSelectedSumBy];
130
117
  };