@parca/profile 0.16.277 → 0.16.279

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.279](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.278...@parca/profile@0.16.279) (2023-10-17)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.16.278](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.277...@parca/profile@0.16.278) (2023-10-17)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
6
14
  ## [0.16.277](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.276...@parca/profile@0.16.277) (2023-10-16)
7
15
 
8
16
  **Note:** Version bump only for package @parca/profile
@@ -13,9 +13,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  // limitations under the License.
14
14
  import { Icon } from '@iconify/react';
15
15
  import { Item, Menu, Submenu } from 'react-contexify';
16
- import { selectDarkMode, useAppSelector } from '@parca/store';
16
+ import { useParcaContext } from '@parca/components';
17
17
  const MetricsContextMenu = ({ menuId, onAddLabelMatcher, highlighted, trackVisibility, }) => {
18
- const isDarkMode = useAppSelector(selectDarkMode);
18
+ const { isDarkMode } = useParcaContext();
19
19
  const labels = highlighted?.labels.filter((label) => label.name !== '__name__');
20
20
  const handleFocusOnSingleSeries = () => {
21
21
  const labelsToAdd = labels?.map((label) => ({
@@ -83,7 +83,7 @@ export const RawMetricsGraph = ({ data, from, to, profile, onSampleClick, addLab
83
83
  const xScale = d3
84
84
  .scaleUtc()
85
85
  .domain([from, to])
86
- .range([0, width - 2 * margin]);
86
+ .range([0, width - 2.5 * margin]);
87
87
  const yScale = d3
88
88
  .scaleLinear()
89
89
  // tslint:disable-next-line
@@ -236,13 +236,23 @@ export const RawMetricsGraph = ({ data, from, to, profile, onSampleClick, addLab
236
236
  const trackVisibility = (isVisible) => {
237
237
  setIsContextMenuOpen(isVisible);
238
238
  };
239
- return (_jsxs(_Fragment, { children: [_jsx(MetricsContextMenu, { onAddLabelMatcher: addLabelMatcher, menuId: MENU_ID, highlighted: highlighted, trackVisibility: trackVisibility }), highlighted != null && hovering && !dragging && pos[0] !== 0 && pos[1] !== 0 && (_jsx("div", { onMouseMove: onMouseMove, onMouseEnter: () => setHovering(true), onMouseLeave: () => setHovering(false), children: !isContextMenuOpen && (_jsx(MetricsTooltip, { x: pos[0] + margin, y: pos[1] + margin, highlighted: highlighted, contextElement: graph.current, sampleUnit: sampleUnit, delta: profile !== null ? profile?.query.profType.delta : false })) })), _jsx("div", { ref: graph, onMouseEnter: function () {
239
+ const isDeltaType = profile !== null ? profile?.query.profType.delta : false;
240
+ let yAxisLabel = sampleUnit;
241
+ if (isDeltaType) {
242
+ if (profile?.query.profType.periodType === 'cpu' && sampleUnit === 'count') {
243
+ yAxisLabel = 'CPU Cores';
244
+ }
245
+ if (sampleUnit === 'bytes') {
246
+ yAxisLabel = 'Bytes per Second';
247
+ }
248
+ }
249
+ return (_jsxs(_Fragment, { children: [_jsx(MetricsContextMenu, { onAddLabelMatcher: addLabelMatcher, menuId: MENU_ID, highlighted: highlighted, trackVisibility: trackVisibility }), highlighted != null && hovering && !dragging && pos[0] !== 0 && pos[1] !== 0 && (_jsx("div", { onMouseMove: onMouseMove, onMouseEnter: () => setHovering(true), onMouseLeave: () => setHovering(false), children: !isContextMenuOpen && (_jsx(MetricsTooltip, { x: pos[0] + margin, y: pos[1] + margin, highlighted: highlighted, contextElement: graph.current, sampleUnit: sampleUnit, delta: isDeltaType })) })), _jsx("div", { ref: graph, onMouseEnter: function () {
240
250
  setHovering(true);
241
- }, onMouseLeave: () => setHovering(false), onContextMenu: displayMenu, children: _jsxs("svg", { width: `${width}px`, height: `${height + margin}px`, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onMouseMove: onMouseMove, children: [_jsx("g", { transform: `translate(${margin}, 0)`, children: dragging && (_jsx("g", { className: "zoom-time-rect", children: _jsx("rect", { className: "bar", x: pos[0] - relPos < 0 ? pos[0] : relPos, y: 0, height: height, width: Math.abs(pos[0] - relPos), fill: 'rgba(0, 0, 0, 0.125)' }) })) }), _jsxs("g", { transform: `translate(${margin}, ${margin / 1.5})`, children: [_jsxs("g", { className: "y axis", textAnchor: "end", fontSize: "10", fill: "none", children: [yScale.ticks(5).map((d, i) => (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
251
+ }, onMouseLeave: () => setHovering(false), onContextMenu: displayMenu, children: _jsxs("svg", { width: `${width}px`, height: `${height + margin}px`, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onMouseMove: onMouseMove, children: [_jsx("g", { transform: `translate(${margin}, 0)`, children: dragging && (_jsx("g", { className: "zoom-time-rect", children: _jsx("rect", { className: "bar", x: pos[0] - relPos < 0 ? pos[0] : relPos, y: 0, height: height, width: Math.abs(pos[0] - relPos), fill: 'rgba(0, 0, 0, 0.125)' }) })) }), _jsxs("g", { transform: `translate(${margin * 1.5}, ${margin / 1.5})`, children: [_jsxs("g", { className: "y axis", textAnchor: "end", fontSize: "10", fill: "none", children: [yScale.ticks(5).map((d, i) => (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
242
252
  /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
243
- transform: `translate(0, ${yScale(d)})`, children: [_jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x2: -6 }), _jsx("text", { fill: "currentColor", x: -9, dy: '0.32em', children: valueFormatter(d, sampleUnit, 1) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(from), x2: xScale(to), y1: yScale(d), y2: yScale(d) }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`))), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: 0, y1: 0, y2: height - margin }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(to), x2: xScale(to), y1: 0, y2: height - margin })] }), _jsxs("g", { className: "x axis", fill: "none", fontSize: "10", textAnchor: "middle", transform: `translate(0,${height - margin})`, children: [xScale.ticks(5).map((d, i) => (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
253
+ transform: `translate(0, ${yScale(d)})`, children: [_jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x2: -6 }), _jsx("text", { fill: "currentColor", x: -9, dy: '0.32em', children: valueFormatter(d, sampleUnit, 1) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(from), x2: xScale(to), y1: yScale(d), y2: yScale(d) }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`))), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: 0, y1: 0, y2: height - margin }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(to), x2: xScale(to), y1: 0, y2: height - margin }), _jsx("g", { transform: `translate(${-margin}, ${(height - margin) / 2}) rotate(270)`, children: _jsx("text", { fill: "currentColor", dy: "-0.7em", className: "text-sm capitalize", textAnchor: "middle", children: yAxisLabel }) })] }), _jsxs("g", { className: "x axis", fill: "none", fontSize: "10", textAnchor: "middle", transform: `translate(0,${height - margin})`, children: [xScale.ticks(5).map((d, i) => (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
244
254
  /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
245
- transform: `translate(${xScale(d)}, 0)`, children: [_jsx("line", { y2: 6, className: "stroke-gray-300 dark:stroke-gray-500" }), _jsx("text", { fill: "currentColor", dy: ".71em", y: 9, children: formatDate(d, formatForTimespan(from, to)) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(d), x2: xScale(d), y1: 0, y2: -height + margin }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`))), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(from), x2: xScale(to), y1: 0, y2: 0 })] }), _jsx("g", { className: "lines fill-transparent", children: series.map((s, i) => (_jsx("g", { className: "line", children: _jsx(MetricsSeries, { data: s, line: l, color: color(i.toString()), strokeWidth: hovering && highlighted != null && i === highlighted.seriesIndex
255
+ transform: `translate(${xScale(d)}, 0)`, children: [_jsx("line", { y2: 6, className: "stroke-gray-300 dark:stroke-gray-500" }), _jsx("text", { fill: "currentColor", dy: ".71em", y: 9, children: formatDate(d, formatForTimespan(from, to)) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(d), x2: xScale(d), y1: 0, y2: -height + margin }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`))), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(from), x2: xScale(to), y1: 0, y2: 0 }), _jsx("g", { transform: `translate(${(width - 2.5 * margin) / 2}, ${margin / 2})`, children: _jsx("text", { fill: "currentColor", dy: ".71em", y: 5, className: "text-sm", children: "Time" }) })] }), _jsx("g", { className: "lines fill-transparent", children: series.map((s, i) => (_jsx("g", { className: "line", children: _jsx(MetricsSeries, { data: s, line: l, color: color(i.toString()), strokeWidth: hovering && highlighted != null && i === highlighted.seriesIndex
246
256
  ? lineStrokeHover
247
257
  : lineStroke, xScale: xScale, yScale: yScale }) }, i))) }), hovering && highlighted != null && (_jsx("g", { className: "circle-group", ref: metricPointRef, style: { fill: color(highlighted.seriesIndex.toString()) }, children: _jsx(MetricsCircle, { cx: highlighted.x, cy: highlighted.y }) })), selected != null && (_jsx("g", { className: "circle-group", style: selected?.seriesIndex != null
248
258
  ? { fill: color(selected.seriesIndex.toString()) }
@@ -16,12 +16,11 @@ import { Item, Menu, Separator, Submenu } from 'react-contexify';
16
16
  import { Tooltip } from 'react-tooltip';
17
17
  import { useParcaContext } from '@parca/components';
18
18
  import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
19
- import { selectDarkMode, useAppSelector } from '@parca/store';
20
19
  import { useGraphTooltip } from '../../GraphTooltipArrow/useGraphTooltip';
21
20
  import { useGraphTooltipMetaInfo } from '../../GraphTooltipArrow/useGraphTooltipMetaInfo';
22
21
  import { hexifyAddress, truncateString } from '../../utils';
23
22
  const ContextMenu = ({ menuId, table, unit, total, totalUnfiltered, row, level, navigateTo, trackVisibility, curPath, setCurPath, hideMenu, }) => {
24
- const isDarkMode = useAppSelector(selectDarkMode);
23
+ const { isDarkMode } = useParcaContext();
25
24
  const { enableSourcesView } = useParcaContext();
26
25
  const [isGraphTooltipDocked, setIsDocked] = useUserPreference(USER_PREFERENCES.GRAPH_METAINFO_DOCKED.key);
27
26
  const contextMenuData = useGraphTooltip({
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.277",
3
+ "version": "0.16.279",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@parca/client": "^0.16.93",
7
- "@parca/components": "^0.16.210",
7
+ "@parca/components": "^0.16.211",
8
8
  "@parca/dynamicsize": "^0.16.59",
9
9
  "@parca/hooks": "^0.0.30",
10
10
  "@parca/parser": "^0.16.63",
@@ -50,5 +50,5 @@
50
50
  "access": "public",
51
51
  "registry": "https://registry.npmjs.org/"
52
52
  },
53
- "gitHead": "d3cd333cbd1f73c1421a62d7411cc56fa56da515"
53
+ "gitHead": "dc3a60af88b6c9b9f6e6d8f0ff9ab88780e36265"
54
54
  }
@@ -15,7 +15,7 @@ import {Icon} from '@iconify/react';
15
15
  import {Item, Menu, Submenu} from 'react-contexify';
16
16
 
17
17
  import {Label} from '@parca/client';
18
- import {selectDarkMode, useAppSelector} from '@parca/store';
18
+ import {useParcaContext} from '@parca/components';
19
19
 
20
20
  import {HighlightedSeries} from '../';
21
21
 
@@ -34,7 +34,7 @@ const MetricsContextMenu = ({
34
34
  highlighted,
35
35
  trackVisibility,
36
36
  }: MetricsContextMenuProps): JSX.Element => {
37
- const isDarkMode = useAppSelector(selectDarkMode);
37
+ const {isDarkMode} = useParcaContext();
38
38
  const labels = highlighted?.labels.filter((label: Label) => label.name !== '__name__');
39
39
 
40
40
  const handleFocusOnSingleSeries = (): void => {
@@ -184,7 +184,7 @@ export const RawMetricsGraph = ({
184
184
  const xScale = d3
185
185
  .scaleUtc()
186
186
  .domain([from, to])
187
- .range([0, width - 2 * margin]);
187
+ .range([0, width - 2.5 * margin]);
188
188
 
189
189
  const yScale = d3
190
190
  .scaleLinear()
@@ -381,6 +381,18 @@ export const RawMetricsGraph = ({
381
381
  setIsContextMenuOpen(isVisible);
382
382
  };
383
383
 
384
+ const isDeltaType = profile !== null ? profile?.query.profType.delta : false;
385
+
386
+ let yAxisLabel = sampleUnit;
387
+ if (isDeltaType) {
388
+ if (profile?.query.profType.periodType === 'cpu' && sampleUnit === 'count') {
389
+ yAxisLabel = 'CPU Cores';
390
+ }
391
+ if (sampleUnit === 'bytes') {
392
+ yAxisLabel = 'Bytes per Second';
393
+ }
394
+ }
395
+
384
396
  return (
385
397
  <>
386
398
  <MetricsContextMenu
@@ -402,7 +414,7 @@ export const RawMetricsGraph = ({
402
414
  highlighted={highlighted}
403
415
  contextElement={graph.current}
404
416
  sampleUnit={sampleUnit}
405
- delta={profile !== null ? profile?.query.profType.delta : false}
417
+ delta={isDeltaType}
406
418
  />
407
419
  )}
408
420
  </div>
@@ -436,7 +448,7 @@ export const RawMetricsGraph = ({
436
448
  </g>
437
449
  )}
438
450
  </g>
439
- <g transform={`translate(${margin}, ${margin / 1.5})`}>
451
+ <g transform={`translate(${margin * 1.5}, ${margin / 1.5})`}>
440
452
  <g className="y axis" textAnchor="end" fontSize="10" fill="none">
441
453
  {yScale.ticks(5).map((d, i) => (
442
454
  <Fragment key={`${i.toString()}-${d.toString()}`}>
@@ -476,6 +488,16 @@ export const RawMetricsGraph = ({
476
488
  y1={0}
477
489
  y2={height - margin}
478
490
  />
491
+ <g transform={`translate(${-margin}, ${(height - margin) / 2}) rotate(270)`}>
492
+ <text
493
+ fill="currentColor"
494
+ dy="-0.7em"
495
+ className="text-sm capitalize"
496
+ textAnchor="middle"
497
+ >
498
+ {yAxisLabel}
499
+ </text>
500
+ </g>
479
501
  </g>
480
502
  <g
481
503
  className="x axis"
@@ -515,6 +537,11 @@ export const RawMetricsGraph = ({
515
537
  y1={0}
516
538
  y2={0}
517
539
  />
540
+ <g transform={`translate(${(width - 2.5 * margin) / 2}, ${margin / 2})`}>
541
+ <text fill="currentColor" dy=".71em" y={5} className="text-sm">
542
+ Time
543
+ </text>
544
+ </g>
518
545
  </g>
519
546
  <g className="lines fill-transparent">
520
547
  {series.map((s, i) => (
@@ -18,7 +18,6 @@ import {Tooltip} from 'react-tooltip';
18
18
 
19
19
  import {useParcaContext} from '@parca/components';
20
20
  import {USER_PREFERENCES, useUserPreference} from '@parca/hooks';
21
- import {selectDarkMode, useAppSelector} from '@parca/store';
22
21
  import {type NavigateFunction} from '@parca/utilities';
23
22
 
24
23
  import {useGraphTooltip} from '../../GraphTooltipArrow/useGraphTooltip';
@@ -54,7 +53,7 @@ const ContextMenu = ({
54
53
  setCurPath,
55
54
  hideMenu,
56
55
  }: ContextMenuProps): JSX.Element => {
57
- const isDarkMode = useAppSelector(selectDarkMode);
56
+ const {isDarkMode} = useParcaContext();
58
57
  const {enableSourcesView} = useParcaContext();
59
58
  const [isGraphTooltipDocked, setIsDocked] = useUserPreference<boolean>(
60
59
  USER_PREFERENCES.GRAPH_METAINFO_DOCKED.key