@parca/profile 0.16.470 → 0.16.472

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/MetricsGraph/UtilizationMetrics/index.d.ts.map +1 -1
  3. package/dist/MetricsGraph/UtilizationMetrics/index.js +5 -2
  4. package/dist/MetricsGraph/useMetricsGraphDimensions.d.ts +1 -1
  5. package/dist/MetricsGraph/useMetricsGraphDimensions.d.ts.map +1 -1
  6. package/dist/MetricsGraph/useMetricsGraphDimensions.js +5 -3
  7. package/dist/MetricsGraphStrips/AreaGraph/Tooltip.d.ts +1 -1
  8. package/dist/MetricsGraphStrips/AreaGraph/Tooltip.d.ts.map +1 -1
  9. package/dist/MetricsGraphStrips/AreaGraph/index.js +1 -1
  10. package/dist/MetricsGraphStrips/MetricsGraphStrips.stories.d.ts +1 -0
  11. package/dist/MetricsGraphStrips/MetricsGraphStrips.stories.d.ts.map +1 -1
  12. package/dist/MetricsGraphStrips/MetricsGraphStrips.stories.js +1 -0
  13. package/dist/MetricsGraphStrips/index.d.ts +2 -1
  14. package/dist/MetricsGraphStrips/index.d.ts.map +1 -1
  15. package/dist/MetricsGraphStrips/index.js +4 -14
  16. package/dist/ProfileSelector/MetricsGraphSection.d.ts +1 -1
  17. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  18. package/dist/ProfileSelector/MetricsGraphSection.js +1 -1
  19. package/dist/ProfileSelector/index.d.ts +1 -1
  20. package/dist/ProfileSelector/index.d.ts.map +1 -1
  21. package/dist/ProfileSelector/index.js +1 -1
  22. package/package.json +6 -6
  23. package/src/MetricsGraph/UtilizationMetrics/index.tsx +7 -3
  24. package/src/MetricsGraph/useMetricsGraphDimensions.ts +8 -3
  25. package/src/MetricsGraphStrips/AreaGraph/Tooltip.tsx +1 -1
  26. package/src/MetricsGraphStrips/AreaGraph/index.tsx +1 -1
  27. package/src/MetricsGraphStrips/MetricsGraphStrips.stories.tsx +1 -0
  28. package/src/MetricsGraphStrips/index.tsx +5 -14
  29. package/src/ProfileSelector/MetricsGraphSection.tsx +13 -11
  30. package/src/ProfileSelector/index.tsx +2 -2
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.472](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.471...@parca/profile@0.16.472) (2025-02-13)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.16.471](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.470...@parca/profile@0.16.471) (2025-02-13)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
6
14
  ## 0.16.470 (2025-02-12)
7
15
 
8
16
  **Note:** Version bump only for package @parca/profile
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraph/UtilizationMetrics/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAC,aAAa,EAAwC,MAAM,mBAAmB,CAAC;AAUvF,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAaD,UAAU,KAAK;IACb,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,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,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAgaD,QAAA,MAAM,kBAAkB,wEAKrB,KAAK,KAAG,GAAG,CAAC,OA4Bd,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraph/UtilizationMetrics/index.tsx"],"names":[],"mappings":"AAqBA,OAAO,EAAC,aAAa,EAAwC,MAAM,mBAAmB,CAAC;AAUvF,UAAU,YAAY;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;IACF,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;KACvB,CAAC;CACH;AAaD,UAAU,KAAK;IACb,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,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,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAoaD,QAAA,MAAM,kBAAkB,wEAKrB,KAAK,KAAG,GAAG,CAAC,OA4Bd,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -114,6 +114,9 @@ const RawUtilizationMetrics = ({ data, addLabelMatcher, setTimeRange, width, hei
114
114
  const color = d3.scaleOrdinal(d3.schemeCategory10);
115
115
  const l = d3.line(d => xScale(d[0]), d => yScale(d[1]));
116
116
  const highlighted = useMemo(() => {
117
+ if (series.length === 0) {
118
+ return null;
119
+ }
117
120
  // Return the closest point as the highlighted point
118
121
  const closestPointPerSeries = series.map(function (s) {
119
122
  const distances = s.values.map(d => {
@@ -205,7 +208,7 @@ const RawUtilizationMetrics = ({ data, addLabelMatcher, setTimeRange, width, hei
205
208
  };
206
209
  const UtilizationMetrics = ({ data, addLabelMatcher, setTimeRange, utilizationMetricsLoading, }) => {
207
210
  const { isDarkMode } = useParcaContext();
208
- const { width, height, margin, heightStyle } = useMetricsGraphDimensions(false);
209
- return (_jsx(AnimatePresence, { children: _jsx(motion.div, { className: "h-full w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: utilizationMetricsLoading === true ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode })) : (_jsx(RawUtilizationMetrics, { data: data, addLabelMatcher: addLabelMatcher, setTimeRange: setTimeRange, width: width, height: height, margin: margin })) }, "utilization-metrics-graph-loaded") }));
211
+ const { width, height, margin, heightStyle } = useMetricsGraphDimensions(false, true);
212
+ return (_jsx(AnimatePresence, { children: _jsx(motion.div, { className: "w-full relative", initial: { display: 'none', opacity: 0 }, animate: { display: 'block', opacity: 1 }, transition: { duration: 0.5 }, children: utilizationMetricsLoading === true ? (_jsx(MetricsGraphSkeleton, { heightStyle: heightStyle, isDarkMode: isDarkMode, isMini: true })) : (_jsx(RawUtilizationMetrics, { data: data, addLabelMatcher: addLabelMatcher, setTimeRange: setTimeRange, width: width, height: height, margin: margin })) }, "utilization-metrics-graph-loaded") }));
210
213
  };
211
214
  export default UtilizationMetrics;
@@ -4,6 +4,6 @@ interface MetricsGraphDimensions {
4
4
  heightStyle: string;
5
5
  margin: number;
6
6
  }
7
- export declare const useMetricsGraphDimensions: (comparing: boolean) => MetricsGraphDimensions;
7
+ export declare const useMetricsGraphDimensions: (comparing: boolean, isMini?: boolean) => MetricsGraphDimensions;
8
8
  export {};
9
9
  //# sourceMappingURL=useMetricsGraphDimensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useMetricsGraphDimensions.d.ts","sourceRoot":"","sources":["../../src/MetricsGraph/useMetricsGraphDimensions.ts"],"names":[],"mappings":"AAiBA,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,eAAO,MAAM,yBAAyB,cAAe,OAAO,KAAG,sBA2B9D,CAAC"}
1
+ {"version":3,"file":"useMetricsGraphDimensions.d.ts","sourceRoot":"","sources":["../../src/MetricsGraph/useMetricsGraphDimensions.ts"],"names":[],"mappings":"AAiBA,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAMD,eAAO,MAAM,yBAAyB,cACzB,OAAO,uBAEjB,sBA4BF,CAAC"}
@@ -12,9 +12,11 @@
12
12
  // limitations under the License.
13
13
  import { useWindowSize } from 'react-use';
14
14
  import { useParcaContext } from '@parca/components';
15
- const maxHeight = 402;
15
+ const MAX_HEIGHT = 402;
16
+ const MINI_VARIANT_HEIGHT = 100;
16
17
  const margin = 50;
17
- export const useMetricsGraphDimensions = (comparing) => {
18
+ export const useMetricsGraphDimensions = (comparing, isMini = false) => {
19
+ const maxHeight = isMini ? MINI_VARIANT_HEIGHT : MAX_HEIGHT;
18
20
  let { width } = useWindowSize();
19
21
  const { profileExplorer } = useParcaContext();
20
22
  if (profileExplorer == null) {
@@ -29,7 +31,7 @@ export const useMetricsGraphDimensions = (comparing) => {
29
31
  if (comparing) {
30
32
  width = width / 2 - 32;
31
33
  }
32
- const height = Math.min(width / 2.5, maxHeight);
34
+ const height = isMini ? MINI_VARIANT_HEIGHT : Math.min(width / 2.5, maxHeight);
33
35
  const heightStyle = `min(${maxHeight + margin}px, ${comparing
34
36
  ? profileExplorer.metricsGraph.maxHeightStyle.compareMode
35
37
  : profileExplorer.metricsGraph.maxHeightStyle.default})`;
@@ -1,7 +1,7 @@
1
1
  interface TooltipProps {
2
2
  x: number;
3
3
  y: number;
4
- timestamp: Date;
4
+ timestamp: Date | number;
5
5
  value: number;
6
6
  containerWidth: number;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraphStrips/AreaGraph/Tooltip.tsx"],"names":[],"mappings":"AAkBA,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,OAAO,CAAC,EAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAC,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAwD3F"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraphStrips/AreaGraph/Tooltip.tsx"],"names":[],"mappings":"AAkBA,UAAU,YAAY;IACpB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,OAAO,CAAC,EAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAC,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAwD3F"}
@@ -192,5 +192,5 @@ export const AreaGraph = ({ data, height, width, marginLeft = 0, marginRight = 0
192
192
  hoverData !== null &&
193
193
  !isDragging &&
194
194
  !isHoveringDragHandle &&
195
- isMouseOverGraph && (_jsx(Tooltip, { x: mousePosition[0], y: mousePosition[1], timestamp: new Date(hoverData.timestamp), value: hoverData.value, containerWidth: width })), _jsx("svg", { style: { width: '100%', height: '100%' }, children: _jsx("path", { fill: fill, d: area(data), className: "opacity-80" }) })] }));
195
+ isMouseOverGraph && (_jsx(Tooltip, { x: mousePosition[0], y: mousePosition[1], timestamp: hoverData.timestamp, value: hoverData.value, containerWidth: width })), _jsx("svg", { style: { width: '100%', height: '100%' }, children: _jsx("path", { fill: fill, d: area(data), className: "opacity-80" }) })] }));
196
196
  };
@@ -17,6 +17,7 @@ export declare const ThreeCPUStrips: {
17
17
  bounds: number[];
18
18
  };
19
19
  onSelectedTimeframe: (index: number, bounds: NumberDuo) => void;
20
+ bounds: number[];
20
21
  };
21
22
  render: (args: any) => JSX.Element;
22
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MetricsGraphStrips.stories.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/MetricsGraphStrips.stories.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAqBtC,QAAA,MAAM,IAAI,EAAE,IAGX,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,cAAc;;;;;;;;;;;;;qCAKM,MAAM,UAAU,SAAS,KAAG,IAAI;;mBAI9B,GAAG,KAAG,GAAG,CAAC,OAAO;CAUnD,CAAC"}
1
+ {"version":3,"file":"MetricsGraphStrips.stories.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/MetricsGraphStrips.stories.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAEtC,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAqBtC,QAAA,MAAM,IAAI,EAAE,IAGX,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,cAAc;;;;;;;;;;;;;qCAKM,MAAM,UAAU,SAAS,KAAG,IAAI;;;mBAK9B,GAAG,KAAG,GAAG,CAAC,OAAO;CAUnD,CAAC"}
@@ -43,6 +43,7 @@ export const ThreeCPUStrips = {
43
43
  onSelectedTimeframe: (index, bounds) => {
44
44
  console.log('onSelectedTimeframe', index, bounds);
45
45
  },
46
+ bounds: [mockData[0][0].timestamp, mockData[0][mockData[0].length - 1].timestamp],
46
47
  },
47
48
  render: function Component(args) {
48
49
  const [, setArgs] = useArgs();
@@ -10,8 +10,9 @@ interface Props {
10
10
  };
11
11
  onSelectedTimeframe: (labels: LabelSet, bounds: NumberDuo | undefined) => void;
12
12
  width?: number;
13
+ bounds: NumberDuo;
13
14
  }
14
15
  export declare const labelSetToString: (labelSet?: LabelSet) => string;
15
- export declare const MetricsGraphStrips: ({ cpus, data, selectedTimeframe, onSelectedTimeframe, width, }: Props) => JSX.Element;
16
+ export declare const MetricsGraphStrips: ({ cpus, data, selectedTimeframe, onSelectedTimeframe, width, bounds, }: Props) => JSX.Element;
16
17
  export {};
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAY,SAAS,EAAC,MAAM,aAAa,CAAC;AAEjD,UAAU,KAAK;IACb,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACpB,iBAAiB,CAAC,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,SAAS,CAAC;KACnB,CAAC;IACF,mBAAmB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,gBAAgB,cAAe,QAAQ,KAAG,MAmBtD,CAAC;AAMF,eAAO,MAAM,kBAAkB,mEAM5B,KAAK,KAAG,GAAG,CAAC,OAmEd,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/MetricsGraphStrips/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AACnC,OAAO,EAAY,SAAS,EAAC,MAAM,aAAa,CAAC;AAEjD,UAAU,KAAK;IACb,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACpB,iBAAiB,CAAC,EAAE;QAClB,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,SAAS,CAAC;KACnB,CAAC;IACF,mBAAmB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,eAAO,MAAM,gBAAgB,cAAe,QAAQ,KAAG,MAmBtD,CAAC;AAMF,eAAO,MAAM,kBAAkB,2EAO5B,KAAK,KAAG,GAAG,CAAC,OAwDd,CAAC"}
@@ -11,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { useMemo, useState } from 'react';
14
+ import { useState } from 'react';
15
15
  import { Icon } from '@iconify/react';
16
16
  import * as d3 from 'd3';
17
17
  import isEqual from 'fast-deep-equal';
@@ -36,21 +36,11 @@ export const labelSetToString = (labelSet) => {
36
36
  const getTimelineGuideHeight = (cpus, collapsedIndices) => {
37
37
  return 56 * (cpus.length - collapsedIndices.length) + 20 * collapsedIndices.length + 24;
38
38
  };
39
- export const MetricsGraphStrips = ({ cpus, data, selectedTimeframe, onSelectedTimeframe, width, }) => {
39
+ export const MetricsGraphStrips = ({ cpus, data, selectedTimeframe, onSelectedTimeframe, width, bounds, }) => {
40
40
  const [collapsedIndices, setCollapsedIndices] = useState([]);
41
41
  // @ts-expect-error
42
42
  const color = d3.scaleOrdinal(d3.schemeObservable10);
43
- const bounds = useMemo(() => {
44
- const bounds = data.length > 0 ? [Infinity, -Infinity] : [0, 1];
45
- data.forEach(cpuData => {
46
- cpuData.forEach(dataPoint => {
47
- bounds[0] = Math.min(bounds[0], dataPoint.timestamp);
48
- bounds[1] = Math.max(bounds[1], dataPoint.timestamp);
49
- });
50
- });
51
- return [0, bounds[1] - bounds[0]];
52
- }, [data]);
53
- return (_jsxs("div", { className: "flex flex-col gap-1 relative my-0 ml-[70px]", style: { width: width ?? '100%' }, children: [_jsx(TimelineGuide, { bounds: [BigInt(bounds[0]), BigInt(bounds[1])], width: width ?? 1468, height: getTimelineGuideHeight(cpus, collapsedIndices), margin: 1 }), cpus.map((cpu, i) => {
43
+ return (_jsxs("div", { className: "flex flex-col gap-1 relative my-0 ml-[70px]", style: { width: width ?? '100%' }, children: [_jsx(TimelineGuide, { bounds: [BigInt(0), BigInt(bounds[1] - bounds[0])], width: width ?? 1468, height: getTimelineGuideHeight(cpus, collapsedIndices), margin: 1 }), cpus.map((cpu, i) => {
54
44
  const isCollapsed = collapsedIndices.includes(i);
55
45
  const labelStr = labelSetToString(cpu);
56
46
  return (_jsxs("div", { className: "relative min-h-5", style: { width: width ?? 1468 }, children: [_jsxs("div", { className: "text-xs absolute top-0 left-0 flex gap-[2px] items-center bg-white/50 px-1 rounded-sm cursor-pointer", style: {
@@ -64,7 +54,7 @@ export const MetricsGraphStrips = ({ cpus, data, selectedTimeframe, onSelectedTi
64
54
  newCollapsedIndices.push(i);
65
55
  }
66
56
  setCollapsedIndices(newCollapsedIndices);
67
- }, children: [_jsx(Icon, { icon: isCollapsed ? 'bxs:right-arrow' : 'bxs:down-arrow' }), labelStr] }), !isCollapsed ? (_jsx(AreaGraph, { data: data[i], height: 56, width: width ?? 1468, fill: color(labelStr), selectionBounds: isEqual(cpu, selectedTimeframe?.labels) ? selectedTimeframe?.bounds : undefined, setSelectionBounds: bounds => {
57
+ }, children: [_jsx(Icon, { icon: isCollapsed ? 'bxs:right-arrow' : 'bxs:down-arrow' }), labelStr] }), !isCollapsed ? (_jsx(AreaGraph, { data: data[i], height: 24, width: width ?? 1468, fill: color(labelStr), selectionBounds: isEqual(cpu, selectedTimeframe?.labels) ? selectedTimeframe?.bounds : undefined, setSelectionBounds: bounds => {
68
58
  onSelectedTimeframe(cpu, bounds);
69
59
  } })) : null] }, labelStr));
70
60
  })] }));
@@ -5,7 +5,7 @@ import { ProfileSelection } from '..';
5
5
  import { QuerySelection, type UtilizationMetrics as UtilizationMetricsType } from './index';
6
6
  interface MetricsGraphSectionProps {
7
7
  showMetricsGraph: boolean;
8
- setDisplayHideMetricsGraphButton: (show: boolean) => void;
8
+ setDisplayHideMetricsGraphButton?: (show: boolean) => void;
9
9
  heightStyle: string;
10
10
  querySelection: QuerySelection;
11
11
  profileSelection: ProfileSelection | null;
@@ -1 +1 @@
1
- {"version":3,"file":"MetricsGraphSection.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/MetricsGraphSection.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAQ,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAyB,gBAAgB,EAAC,MAAM,IAAI,CAAC;AAG5D,OAAO,EAAC,cAAc,EAAE,KAAK,kBAAkB,IAA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ChB,gCAAgC,EAChC,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,KAAK,EACL,mBAAmB,EACnB,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,KAAK,EACL,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,GAC1B,EAAE,wBAAwB,GAAG,GAAG,CAAC,OAAO,CAkIxC"}
@@ -75,7 +75,7 @@ export function MetricsGraphSection({ showMetricsGraph, setDisplayHideMetricsGra
75
75
  const mergeTo = query.profileType().delta ? mergeFrom + durationInMilliseconds : mergeFrom;
76
76
  selectProfile(new MergedProfileSelection(mergeFrom, mergeTo, query));
77
77
  };
78
- return (_jsxs("div", { className: cx('relative', { 'py-4': !showMetricsGraph }), children: [_jsxs("button", { onClick: () => setDisplayHideMetricsGraphButton(!showMetricsGraph), className: cx('hidden z-10 px-3 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 bg-gray-100 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:bg-gray-900', showMetricsGraph && 'absolute right-0 bottom-3 !flex', !showMetricsGraph && 'relative !flex ml-auto'), children: [showMetricsGraph ? 'Hide' : 'Show', " Metrics Graph"] }), showMetricsGraph && (_jsx(_Fragment, { children: _jsx("div", { style: { height: heightStyle }, children: querySelection.expression !== '' &&
78
+ return (_jsxs("div", { className: cx('relative', { 'py-4': !showMetricsGraph }), children: [setDisplayHideMetricsGraphButton != null ? (_jsxs("button", { onClick: () => setDisplayHideMetricsGraphButton(!showMetricsGraph), className: cx('hidden px-3 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 bg-gray-100 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:bg-gray-900', showMetricsGraph && 'absolute right-0 bottom-3 !flex', !showMetricsGraph && 'relative !flex ml-auto'), children: [showMetricsGraph ? 'Hide' : 'Show', " Metrics Graph"] })) : null, showMetricsGraph && (_jsx(_Fragment, { children: _jsx("div", { style: { height: heightStyle }, children: querySelection.expression !== '' &&
79
79
  querySelection.from !== undefined &&
80
80
  querySelection.to !== undefined ? (_jsx(_Fragment, { children: utilizationMetrics !== undefined ? (_jsx(UtilizationMetricsGraph, { data: utilizationMetrics, addLabelMatcher: addLabelMatcher, setTimeRange: handleTimeRangeChange, utilizationMetricsLoading: utilizationMetricsLoading })) : (_jsx(_Fragment, { children: _jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, sumBy: querySelection.sumBy ?? sumBy ?? [], sumByLoading: defaultSumByLoading, setTimeRange: handleTimeRangeChange, addLabelMatcher: addLabelMatcher, onPointClick: handlePointClick }) })) })) : (profileSelection === null && (_jsx("div", { className: "p-2", children: _jsx(ProfileMetricsEmptyState, { message: "Please select a profile type and click 'Search' to begin." }) }))) }) }))] }));
81
81
  }
@@ -44,7 +44,7 @@ interface ProfileSelectorProps extends ProfileSelectorFeatures {
44
44
  profileSelection: ProfileSelection | null;
45
45
  comparing: boolean;
46
46
  navigateTo: NavigateFunction;
47
- setDisplayHideMetricsGraphButton: Dispatch<SetStateAction<boolean>>;
47
+ setDisplayHideMetricsGraphButton?: Dispatch<SetStateAction<boolean>>;
48
48
  suffix?: string;
49
49
  utilizationMetrics?: UtilizationMetrics[];
50
50
  utilizationMetricsLoading?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileSelector/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAuC,MAAM,OAAO,CAAC;AAErF,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAC,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAUvE,OAAO,EAAC,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAEvD,OAA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,CAAC;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC1C,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;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,2UAkBlB,oBAAoB,KAAG,GAAG,CAAC,OA4M7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -41,7 +41,7 @@ export const useProfileTypes = (client) => {
41
41
  };
42
42
  const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, navigateTo, showMetricsGraph = true, showSumBySelector = true, showProfileTypeSelector = true, disableExplorativeQuerying = false, setDisplayHideMetricsGraphButton, utilizationMetrics, utilizationMetricsLoading, utilizationLabels, }) => {
43
43
  const { loading: profileTypesLoading, data: profileTypesData, error, } = useProfileTypes(queryClient);
44
- const { heightStyle } = useMetricsGraphDimensions(comparing);
44
+ const { heightStyle } = useMetricsGraphDimensions(comparing, utilizationMetrics != null);
45
45
  const { viewComponent } = useParcaContext();
46
46
  const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');
47
47
  const [timeRangeSelection, setTimeRangeSelection] = useState(DateTimeRange.fromRangeKey(querySelection.timeSelection, querySelection.from, querySelection.to));
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.470",
3
+ "version": "0.16.472",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@headlessui/react": "^1.7.19",
7
7
  "@iconify/react": "^4.0.0",
8
8
  "@parca/client": "0.16.127",
9
- "@parca/components": "0.16.321",
9
+ "@parca/components": "0.16.323",
10
10
  "@parca/dynamicsize": "0.16.65",
11
- "@parca/hooks": "0.0.79",
11
+ "@parca/hooks": "0.0.80",
12
12
  "@parca/icons": "0.16.71",
13
13
  "@parca/parser": "0.16.78",
14
- "@parca/store": "0.16.165",
15
- "@parca/utilities": "0.0.91",
14
+ "@parca/store": "0.16.166",
15
+ "@parca/utilities": "0.0.92",
16
16
  "@popperjs/core": "^2.11.8",
17
17
  "@protobuf-ts/runtime-rpc": "^2.5.0",
18
18
  "@storybook/preview-api": "^8.4.3",
@@ -75,5 +75,5 @@
75
75
  "access": "public",
76
76
  "registry": "https://registry.npmjs.org/"
77
77
  },
78
- "gitHead": "487d4b97e6da9903b123b9292c214c0b17796d93"
78
+ "gitHead": "9cacf5cf50474571ee0357b10bdfde884921d086"
79
79
  }
@@ -189,6 +189,10 @@ const RawUtilizationMetrics = ({
189
189
  );
190
190
 
191
191
  const highlighted = useMemo(() => {
192
+ if (series.length === 0) {
193
+ return null;
194
+ }
195
+
192
196
  // Return the closest point as the highlighted point
193
197
  const closestPointPerSeries = series.map(function (s) {
194
198
  const distances = s.values.map(d => {
@@ -481,19 +485,19 @@ const UtilizationMetrics = ({
481
485
  utilizationMetricsLoading,
482
486
  }: Props): JSX.Element => {
483
487
  const {isDarkMode} = useParcaContext();
484
- const {width, height, margin, heightStyle} = useMetricsGraphDimensions(false);
488
+ const {width, height, margin, heightStyle} = useMetricsGraphDimensions(false, true);
485
489
 
486
490
  return (
487
491
  <AnimatePresence>
488
492
  <motion.div
489
- className="h-full w-full relative"
493
+ className="w-full relative"
490
494
  key="utilization-metrics-graph-loaded"
491
495
  initial={{display: 'none', opacity: 0}}
492
496
  animate={{display: 'block', opacity: 1}}
493
497
  transition={{duration: 0.5}}
494
498
  >
495
499
  {utilizationMetricsLoading === true ? (
496
- <MetricsGraphSkeleton heightStyle={heightStyle} isDarkMode={isDarkMode} />
500
+ <MetricsGraphSkeleton heightStyle={heightStyle} isDarkMode={isDarkMode} isMini={true} />
497
501
  ) : (
498
502
  <RawUtilizationMetrics
499
503
  data={data}
@@ -22,10 +22,15 @@ interface MetricsGraphDimensions {
22
22
  margin: number;
23
23
  }
24
24
 
25
- const maxHeight = 402;
25
+ const MAX_HEIGHT = 402;
26
+ const MINI_VARIANT_HEIGHT = 100;
26
27
  const margin = 50;
27
28
 
28
- export const useMetricsGraphDimensions = (comparing: boolean): MetricsGraphDimensions => {
29
+ export const useMetricsGraphDimensions = (
30
+ comparing: boolean,
31
+ isMini = false
32
+ ): MetricsGraphDimensions => {
33
+ const maxHeight = isMini ? MINI_VARIANT_HEIGHT : MAX_HEIGHT;
29
34
  let {width} = useWindowSize();
30
35
  const {profileExplorer} = useParcaContext();
31
36
  if (profileExplorer == null) {
@@ -40,7 +45,7 @@ export const useMetricsGraphDimensions = (comparing: boolean): MetricsGraphDimen
40
45
  if (comparing) {
41
46
  width = width / 2 - 32;
42
47
  }
43
- const height = Math.min(width / 2.5, maxHeight);
48
+ const height = isMini ? MINI_VARIANT_HEIGHT : Math.min(width / 2.5, maxHeight);
44
49
  const heightStyle = `min(${maxHeight + margin}px, ${
45
50
  comparing
46
51
  ? profileExplorer.metricsGraph.maxHeightStyle.compareMode
@@ -19,7 +19,7 @@ import {formatDateTimeDownToMS, valueFormatter} from '@parca/utilities';
19
19
  interface TooltipProps {
20
20
  x: number;
21
21
  y: number;
22
- timestamp: Date;
22
+ timestamp: Date | number;
23
23
  value: number;
24
24
  containerWidth: number;
25
25
  }
@@ -352,7 +352,7 @@ export const AreaGraph = ({
352
352
  <Tooltip
353
353
  x={mousePosition[0]}
354
354
  y={mousePosition[1]}
355
- timestamp={new Date(hoverData.timestamp)}
355
+ timestamp={hoverData.timestamp}
356
356
  value={hoverData.value}
357
357
  containerWidth={width}
358
358
  />
@@ -52,6 +52,7 @@ export const ThreeCPUStrips = {
52
52
  onSelectedTimeframe: (index: number, bounds: NumberDuo): void => {
53
53
  console.log('onSelectedTimeframe', index, bounds);
54
54
  },
55
+ bounds: [mockData[0][0].timestamp, mockData[0][mockData[0].length - 1].timestamp],
55
56
  },
56
57
  render: function Component(args: any): JSX.Element {
57
58
  const [, setArgs] = useArgs();
@@ -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 {useMemo, useState} from 'react';
14
+ import {useState} from 'react';
15
15
 
16
16
  import {Icon} from '@iconify/react';
17
17
  import * as d3 from 'd3';
@@ -32,6 +32,7 @@ interface Props {
32
32
  };
33
33
  onSelectedTimeframe: (labels: LabelSet, bounds: NumberDuo | undefined) => void;
34
34
  width?: number;
35
+ bounds: NumberDuo;
35
36
  }
36
37
 
37
38
  export const labelSetToString = (labelSet?: LabelSet): string => {
@@ -65,27 +66,17 @@ export const MetricsGraphStrips = ({
65
66
  selectedTimeframe,
66
67
  onSelectedTimeframe,
67
68
  width,
69
+ bounds,
68
70
  }: Props): JSX.Element => {
69
71
  const [collapsedIndices, setCollapsedIndices] = useState<number[]>([]);
70
72
 
71
73
  // @ts-expect-error
72
74
  const color = d3.scaleOrdinal(d3.schemeObservable10);
73
75
 
74
- const bounds = useMemo(() => {
75
- const bounds: NumberDuo = data.length > 0 ? [Infinity, -Infinity] : [0, 1];
76
- data.forEach(cpuData => {
77
- cpuData.forEach(dataPoint => {
78
- bounds[0] = Math.min(bounds[0], dataPoint.timestamp);
79
- bounds[1] = Math.max(bounds[1], dataPoint.timestamp);
80
- });
81
- });
82
- return [0, bounds[1] - bounds[0]] as NumberDuo;
83
- }, [data]);
84
-
85
76
  return (
86
77
  <div className="flex flex-col gap-1 relative my-0 ml-[70px]" style={{width: width ?? '100%'}}>
87
78
  <TimelineGuide
88
- bounds={[BigInt(bounds[0]), BigInt(bounds[1])]}
79
+ bounds={[BigInt(0), BigInt(bounds[1] - bounds[0])]}
89
80
  width={width ?? 1468}
90
81
  height={getTimelineGuideHeight(cpus, collapsedIndices)}
91
82
  margin={1}
@@ -116,7 +107,7 @@ export const MetricsGraphStrips = ({
116
107
  {!isCollapsed ? (
117
108
  <AreaGraph
118
109
  data={data[i]}
119
- height={56}
110
+ height={24}
120
111
  width={width ?? 1468}
121
112
  fill={color(labelStr) as string}
122
113
  selectionBounds={
@@ -24,7 +24,7 @@ import {QuerySelection, type UtilizationMetrics as UtilizationMetricsType} from
24
24
 
25
25
  interface MetricsGraphSectionProps {
26
26
  showMetricsGraph: boolean;
27
- setDisplayHideMetricsGraphButton: (show: boolean) => void;
27
+ setDisplayHideMetricsGraphButton?: (show: boolean) => void;
28
28
  heightStyle: string;
29
29
  querySelection: QuerySelection;
30
30
  profileSelection: ProfileSelection | null;
@@ -135,16 +135,18 @@ export function MetricsGraphSection({
135
135
 
136
136
  return (
137
137
  <div className={cx('relative', {'py-4': !showMetricsGraph})}>
138
- <button
139
- onClick={() => setDisplayHideMetricsGraphButton(!showMetricsGraph)}
140
- className={cx(
141
- 'hidden z-10 px-3 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 bg-gray-100 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:bg-gray-900',
142
- showMetricsGraph && 'absolute right-0 bottom-3 !flex',
143
- !showMetricsGraph && 'relative !flex ml-auto'
144
- )}
145
- >
146
- {showMetricsGraph ? 'Hide' : 'Show'} Metrics Graph
147
- </button>
138
+ {setDisplayHideMetricsGraphButton != null ? (
139
+ <button
140
+ onClick={() => setDisplayHideMetricsGraphButton(!showMetricsGraph)}
141
+ className={cx(
142
+ 'hidden px-3 py-1 text-sm font-medium text-gray-700 dark:text-gray-200 bg-gray-100 rounded-md hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:bg-gray-900',
143
+ showMetricsGraph && 'absolute right-0 bottom-3 !flex',
144
+ !showMetricsGraph && 'relative !flex ml-auto'
145
+ )}
146
+ >
147
+ {showMetricsGraph ? 'Hide' : 'Show'} Metrics Graph
148
+ </button>
149
+ ) : null}
148
150
  {showMetricsGraph && (
149
151
  <>
150
152
  <div style={{height: heightStyle}}>
@@ -81,7 +81,7 @@ interface ProfileSelectorProps extends ProfileSelectorFeatures {
81
81
  profileSelection: ProfileSelection | null;
82
82
  comparing: boolean;
83
83
  navigateTo: NavigateFunction;
84
- setDisplayHideMetricsGraphButton: Dispatch<SetStateAction<boolean>>;
84
+ setDisplayHideMetricsGraphButton?: Dispatch<SetStateAction<boolean>>;
85
85
  suffix?: string;
86
86
  utilizationMetrics?: UtilizationMetrics[];
87
87
  utilizationMetricsLoading?: boolean;
@@ -138,7 +138,7 @@ const ProfileSelector = ({
138
138
  data: profileTypesData,
139
139
  error,
140
140
  } = useProfileTypes(queryClient);
141
- const {heightStyle} = useMetricsGraphDimensions(comparing);
141
+ const {heightStyle} = useMetricsGraphDimensions(comparing, utilizationMetrics != null);
142
142
  const {viewComponent} = useParcaContext();
143
143
  const [queryBrowserMode, setQueryBrowserMode] = useURLState('query_browser_mode');
144
144