@parca/profile 0.16.208 → 0.16.209

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.209](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.208...@parca/profile@0.16.209) (2023-07-17)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
6
10
  ## [0.16.208](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.207...@parca/profile@0.16.208) (2023-07-14)
7
11
 
8
12
  **Note:** Version bump only for package @parca/profile
@@ -5,5 +5,5 @@ interface MetricsGraphDimensions {
5
5
  margin: number;
6
6
  marginRight: number;
7
7
  }
8
- export declare const useMetricsGraphDimensions: () => MetricsGraphDimensions;
8
+ export declare const useMetricsGraphDimensions: (comparing: boolean) => MetricsGraphDimensions;
9
9
  export {};
@@ -14,13 +14,18 @@ import { useWindowSize } from 'react-use';
14
14
  import { useParcaContext } from '@parca/components';
15
15
  const maxHeight = 402;
16
16
  const margin = 50;
17
- export const useMetricsGraphDimensions = () => {
17
+ export const useMetricsGraphDimensions = (comparing) => {
18
18
  let { width } = useWindowSize();
19
19
  const { profileExplorer } = useParcaContext();
20
20
  width = width - profileExplorer.PaddingX;
21
+ if (comparing) {
22
+ width = width / 2 - 32;
23
+ }
21
24
  const height = Math.min(width / 2.5, maxHeight);
22
25
  const marginRight = 20;
23
- const heightStyle = `min(${maxHeight + margin}px, ${profileExplorer.metricsGraph.maxHeightStyle})`;
26
+ const heightStyle = `min(${maxHeight + margin}px, ${comparing
27
+ ? profileExplorer.metricsGraph.maxHeightStyle.compareMode
28
+ : profileExplorer.metricsGraph.maxHeightStyle.default})`;
24
29
  return {
25
30
  width,
26
31
  height,
@@ -15,6 +15,7 @@ interface ProfileMetricsGraphProps {
15
15
  setTimeRange: (range: DateTimeRange) => void;
16
16
  addLabelMatcher: (key: string, value: string) => void;
17
17
  onPointClick: (timestamp: number, labels: Label[], queryExpression: string) => void;
18
+ comparing?: boolean;
18
19
  }
19
20
  export interface IQueryRangeState {
20
21
  response: QueryRangeResponse | null;
@@ -22,5 +23,5 @@ export interface IQueryRangeState {
22
23
  error: RpcError | null;
23
24
  }
24
25
  export declare const useQueryRange: (client: QueryServiceClient, queryExpression: string, start: number, end: number) => IQueryRangeState;
25
- declare const ProfileMetricsGraph: ({ queryClient, queryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, }: ProfileMetricsGraphProps) => JSX.Element;
26
+ declare const ProfileMetricsGraph: ({ queryClient, queryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing, }: ProfileMetricsGraphProps) => JSX.Element;
26
27
  export default ProfileMetricsGraph;
@@ -55,11 +55,11 @@ export const useQueryRange = (client, queryExpression, start, end) => {
55
55
  }, [client, queryExpression, start, end, metadata]);
56
56
  return { ...state, isLoading };
57
57
  };
58
- const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, }) => {
58
+ const ProfileMetricsGraph = ({ queryClient, queryExpression, profile, from, to, setTimeRange, addLabelMatcher, onPointClick, comparing = false, }) => {
59
59
  const { isLoading, response, error } = useQueryRange(queryClient, queryExpression, from, to);
60
60
  const isLoaderVisible = useDelayedLoader(isLoading);
61
61
  const { loader, onError, perf } = useParcaContext();
62
- const { width, height, margin, marginRight } = useMetricsGraphDimensions();
62
+ const { width, height, margin, marginRight } = useMetricsGraphDimensions(comparing);
63
63
  useEffect(() => {
64
64
  if (error !== null) {
65
65
  onError?.(error, 'metricsGraph');
@@ -42,7 +42,7 @@ export const useProfileTypes = (client) => {
42
42
  };
43
43
  const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQuery, closeProfile, enforcedProfileName, profileSelection, comparing, onCompareProfile, }) => {
44
44
  const { loading: profileTypesLoading, data: profileTypesData, error, } = useProfileTypes(queryClient);
45
- const { heightStyle } = useMetricsGraphDimensions();
45
+ const { heightStyle } = useMetricsGraphDimensions(comparing);
46
46
  const [timeRangeSelection, setTimeRangeSelection] = useState(DateTimeRange.fromRangeKey(querySelection.timeSelection));
47
47
  const [queryExpressionString, setQueryExpressionString] = useState(querySelection.expression);
48
48
  useEffect(() => {
@@ -125,7 +125,7 @@ const ProfileSelector = ({ queryClient, querySelection, selectProfile, selectQue
125
125
  }, children: "Search" })] })] }), _jsx("div", { children: comparing && _jsx(IconButton, { onClick: () => closeProfile(), icon: _jsx(CloseIcon, {}) }) })] }), _jsx(Card.Body, { children: _jsx("div", { style: { height: heightStyle }, children: querySelection.expression !== undefined &&
126
126
  querySelection.expression.length > 0 &&
127
127
  querySelection.from !== undefined &&
128
- querySelection.to !== undefined ? (_jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, setTimeRange: (range) => {
128
+ querySelection.to !== undefined ? (_jsx(ProfileMetricsGraph, { queryClient: queryClient, queryExpression: querySelection.expression, from: querySelection.from, to: querySelection.to, profile: profileSelection, comparing: comparing, setTimeRange: (range) => {
129
129
  const from = range.getFromMs();
130
130
  const to = range.getToMs();
131
131
  let mergedProfileParams = {};
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.16.208",
3
+ "version": "0.16.209",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
6
  "@parca/client": "^0.16.80",
7
- "@parca/components": "^0.16.167",
7
+ "@parca/components": "^0.16.168",
8
8
  "@parca/dynamicsize": "^0.16.54",
9
9
  "@parca/hooks": "^0.0.15",
10
10
  "@parca/parser": "^0.16.55",
@@ -47,5 +47,5 @@
47
47
  "access": "public",
48
48
  "registry": "https://registry.npmjs.org/"
49
49
  },
50
- "gitHead": "6598149618b644783f5d638b6a913026cb8adc25"
50
+ "gitHead": "e81c1b5d981d8f728a23f867bef27b8922b0285b"
51
51
  }
@@ -26,15 +26,19 @@ interface MetricsGraphDimensions {
26
26
  const maxHeight = 402;
27
27
  const margin = 50;
28
28
 
29
- export const useMetricsGraphDimensions = (): MetricsGraphDimensions => {
29
+ export const useMetricsGraphDimensions = (comparing: boolean): MetricsGraphDimensions => {
30
30
  let {width} = useWindowSize();
31
31
  const {profileExplorer} = useParcaContext();
32
32
  width = width - profileExplorer.PaddingX;
33
-
33
+ if (comparing) {
34
+ width = width / 2 - 32;
35
+ }
34
36
  const height = Math.min(width / 2.5, maxHeight);
35
37
  const marginRight = 20;
36
38
  const heightStyle = `min(${maxHeight + margin}px, ${
37
- profileExplorer.metricsGraph.maxHeightStyle
39
+ comparing
40
+ ? profileExplorer.metricsGraph.maxHeightStyle.compareMode
41
+ : profileExplorer.metricsGraph.maxHeightStyle.default
38
42
  })`;
39
43
  return {
40
44
  width,
@@ -46,6 +46,7 @@ interface ProfileMetricsGraphProps {
46
46
  setTimeRange: (range: DateTimeRange) => void;
47
47
  addLabelMatcher: (key: string, value: string) => void;
48
48
  onPointClick: (timestamp: number, labels: Label[], queryExpression: string) => void;
49
+ comparing?: boolean;
49
50
  }
50
51
 
51
52
  export interface IQueryRangeState {
@@ -109,11 +110,12 @@ const ProfileMetricsGraph = ({
109
110
  setTimeRange,
110
111
  addLabelMatcher,
111
112
  onPointClick,
113
+ comparing = false,
112
114
  }: ProfileMetricsGraphProps): JSX.Element => {
113
115
  const {isLoading, response, error} = useQueryRange(queryClient, queryExpression, from, to);
114
116
  const isLoaderVisible = useDelayedLoader(isLoading);
115
117
  const {loader, onError, perf} = useParcaContext();
116
- const {width, height, margin, marginRight} = useMetricsGraphDimensions();
118
+ const {width, height, margin, marginRight} = useMetricsGraphDimensions(comparing);
117
119
 
118
120
  useEffect(() => {
119
121
  if (error !== null) {
@@ -100,7 +100,7 @@ const ProfileSelector = ({
100
100
  data: profileTypesData,
101
101
  error,
102
102
  } = useProfileTypes(queryClient);
103
- const {heightStyle} = useMetricsGraphDimensions();
103
+ const {heightStyle} = useMetricsGraphDimensions(comparing);
104
104
 
105
105
  const [timeRangeSelection, setTimeRangeSelection] = useState(
106
106
  DateTimeRange.fromRangeKey(querySelection.timeSelection)
@@ -257,6 +257,7 @@ const ProfileSelector = ({
257
257
  from={querySelection.from}
258
258
  to={querySelection.to}
259
259
  profile={profileSelection}
260
+ comparing={comparing}
260
261
  setTimeRange={(range: DateTimeRange) => {
261
262
  const from = range.getFromMs();
262
263
  const to = range.getToMs();