@parca/profile 0.16.363 → 0.16.367

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.
@@ -219,6 +219,13 @@ const ProfileIcicleGraph = function ProfileIcicleGraphNonMemo({
219
219
  navigateTo,
220
220
  });
221
221
 
222
+ const [invertStack = '', setInvertStack] = useURLState({
223
+ param: 'invert_call_stack',
224
+ navigateTo,
225
+ });
226
+
227
+ const isInvert = invertStack === 'true';
228
+
222
229
  const [
223
230
  totalFormatted,
224
231
  totalUnfilteredFormatted,
@@ -263,6 +270,23 @@ const ProfileIcicleGraph = function ProfileIcicleGraphNonMemo({
263
270
  <div className="flex w-full justify-end gap-2 pb-2">
264
271
  <div className="ml-2 flex w-full flex-col items-start justify-between gap-2 md:flex-row md:items-end">
265
272
  {arrow !== undefined && <GroupAndSortActionButtons navigateTo={navigateTo} />}
273
+ {isHalfScreen ? (
274
+ <IconButton
275
+ icon={isInvert ? 'ph:sort-ascending' : 'ph:sort-descending'}
276
+ toolTipText={isInvert ? 'Original Call Stack' : 'Invert Call Stack'}
277
+ onClick={() => setInvertStack(isInvert ? '' : 'true')}
278
+ className="rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 items-center flex border border-gray-200 dark:border-gray-600 dark:text-white justify-center py-2 px-3 cursor-pointer min-h-[38px]"
279
+ />
280
+ ) : (
281
+ <Button
282
+ variant="neutral"
283
+ className="gap-2 w-max"
284
+ onClick={() => setInvertStack(isInvert ? '' : 'true')}
285
+ >
286
+ {isInvert ? 'Original Call Stack' : 'Invert Call Stack'}
287
+ <Icon icon={isInvert ? 'ph:sort-ascending' : 'ph:sort-descending'} width={20} />
288
+ </Button>
289
+ )}
266
290
  <ShowHideLegendButton isHalfScreen={isHalfScreen} navigateTo={navigateTo} />
267
291
  {isHalfScreen ? (
268
292
  <IconButton
@@ -286,7 +310,17 @@ const ProfileIcicleGraph = function ProfileIcicleGraphNonMemo({
286
310
  </div>
287
311
  </div>
288
312
  );
289
- }, [navigateTo, arrow, curPath, setNewCurPath, setActionButtons, loading, isHalfScreen]);
313
+ }, [
314
+ navigateTo,
315
+ isInvert,
316
+ setInvertStack,
317
+ arrow,
318
+ curPath,
319
+ setNewCurPath,
320
+ setActionButtons,
321
+ loading,
322
+ isHalfScreen,
323
+ ]);
290
324
 
291
325
  if (loading) {
292
326
  return (
@@ -66,17 +66,13 @@ const ViewSelector = ({
66
66
  key: string;
67
67
  supportingText?: string;
68
68
  }): SelectElement => {
69
- const capitalizeFirstLetter = (string: string): string => {
70
- return `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
71
- };
72
-
73
- const title = capitalizeFirstLetter(key);
69
+ const title = <span className="capitalize">{key.replaceAll('-', ' ')}</span>;
74
70
 
75
71
  return {
76
- active: <>{title}</>,
72
+ active: title,
77
73
  expanded: (
78
74
  <>
79
- <span>{title}</span>
75
+ {title}
80
76
  {supportingText !== null && <span className="text-xs">{supportingText}</span>}
81
77
  </>
82
78
  ),
@@ -49,6 +49,8 @@ export const ProfileViewWithData = ({
49
49
  const showRuntimePython = showRuntimePythonStr === 'true';
50
50
  const [showInterpretedOnlyStr] = useURLState({param: 'show_interpreted_only', navigateTo});
51
51
  const showInterpretedOnly = showInterpretedOnlyStr === 'true';
52
+ const [invertStack] = useURLState({param: 'invert_call_stack', navigateTo});
53
+ const invertCallStack = invertStack === 'true';
52
54
 
53
55
  const [pprofDownloading, setPprofDownloading] = useState<boolean>(false);
54
56
 
@@ -75,7 +77,9 @@ export const ProfileViewWithData = ({
75
77
  showRuntimeRuby,
76
78
  showRuntimePython,
77
79
  showInterpretedOnly,
80
+ invertCallStack,
78
81
  });
82
+
79
83
  const {perf} = useParcaContext();
80
84
 
81
85
  const {
package/src/index.tsx CHANGED
@@ -11,8 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
 
14
- import type {Props as CallgraphProps} from '@parca/profile/src/Callgraph';
15
-
14
+ import type {Props as CallgraphProps} from './Callgraph';
16
15
  import ProfileExplorer from './ProfileExplorer';
17
16
  import ProfileTypeSelector from './ProfileTypeSelector';
18
17
 
package/src/useQuery.tsx CHANGED
@@ -35,6 +35,7 @@ interface UseQueryOptions {
35
35
  showRuntimeRuby?: boolean;
36
36
  showRuntimePython?: boolean;
37
37
  showInterpretedOnly?: boolean;
38
+ invertCallStack?: boolean;
38
39
  }
39
40
 
40
41
  export const useQuery = (
@@ -58,6 +59,7 @@ export const useQuery = (
58
59
  options?.showRuntimeRuby ?? false,
59
60
  options?.showRuntimePython ?? false,
60
61
  options?.showInterpretedOnly ?? false,
62
+ options?.invertCallStack ?? false,
61
63
  ],
62
64
  queryFn: async () => {
63
65
  const req = profileSource.QueryRequest();
@@ -78,6 +80,7 @@ export const useQuery = (
78
80
  showPython: options?.showRuntimePython ?? false,
79
81
  showInterpretedOnly: options?.showInterpretedOnly ?? false,
80
82
  };
83
+ req.invertCallStack = options?.invertCallStack ?? false;
81
84
 
82
85
  try {
83
86
  const {response} = await client.query(req, {meta: metadata});