@parca/profile 0.10.2 → 0.12.3

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,30 @@
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.12.3](https://github.com/parca-dev/parca/compare/ui-v0.12.2...ui-v0.12.3) (2022-03-21)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.12.2](https://github.com/parca-dev/parca/compare/ui-v0.12.1...ui-v0.12.2) (2022-03-14)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
14
+ # [0.12.0](https://github.com/parca-dev/parca/compare/ui-v0.11.2...ui-v0.12.0) (2022-03-09)
15
+
16
+ **Note:** Version bump only for package @parca/profile
17
+
18
+ # [0.11.0](https://github.com/parca-dev/parca/compare/ui-v0.10.4...ui-v0.11.0) (2022-03-02)
19
+
20
+ ### Features
21
+
22
+ - convert moment.js to date-fns ([9431e15](https://github.com/parca-dev/parca/commit/9431e156d9438353e5542b11e33ed8e0de93547f)), closes [#613](https://github.com/parca-dev/parca/issues/613)
23
+
24
+ ## [0.10.3](https://github.com/parca-dev/parca/compare/ui-v0.10.2...ui-v0.10.3) (2022-03-02)
25
+
26
+ ## 0.10.1 (2022-02-28)
27
+
28
+ **Note:** Version bump only for package @parca/profile
29
+
6
30
  ## [0.10.2](https://github.com/parca-dev/parca/compare/ui-v0.10.1...ui-v0.10.2) (2022-03-01)
7
31
 
8
32
  **Note:** Version bump only for package @parca/profile
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@parca/profile",
3
- "version": "0.10.2",
3
+ "version": "0.12.3",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
- "@parca/client": "^0.10.0",
7
- "@parca/dynamicsize": "^0.10.0",
8
- "@parca/parser": "^0.10.0",
6
+ "@parca/client": "^0.12.2",
7
+ "@parca/dynamicsize": "^0.12.0",
8
+ "@parca/parser": "^0.12.3",
9
9
  "d3-scale": "^4.0.2"
10
10
  },
11
11
  "main": "src/index.tsx",
@@ -19,5 +19,5 @@
19
19
  "access": "public",
20
20
  "registry": "https://registry.npmjs.org/"
21
21
  },
22
- "gitHead": "0a4440a8d15256d3e1ce6868bd58ca08c39a652b"
22
+ "gitHead": "199b5b8d9bc2a596da5606b358df79c7f7e8cb00"
23
23
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import moment from 'moment';
2
+ import {formatDate} from '@parca/functions';
3
3
  import {Query} from '@parca/parser';
4
4
  import {
5
5
  Label,
@@ -25,8 +25,8 @@ export interface ProfileSelection {
25
25
  Type: () => string;
26
26
  }
27
27
 
28
- export const timeFormat = 'MMM D, [at] h:mm:s a [(UTC)]';
29
- export const timeFormatShort = 'MMM D, h:mma';
28
+ export const timeFormat = "MMM d, 'at' h:mm:s a '(UTC)'";
29
+ export const timeFormatShort = 'MMM d, h:mma';
30
30
 
31
31
  export function ParamsString(params: {[key: string]: string}): string {
32
32
  return Object.keys(params)
@@ -157,7 +157,7 @@ export class SingleProfileSource implements ProfileSource {
157
157
 
158
158
  const singleProfile = new SingleProfile();
159
159
  const ts = new Timestamp();
160
- ts.fromDate(moment(this.time).toDate());
160
+ ts.fromDate(new Date(this.time));
161
161
  singleProfile.setTime(ts);
162
162
  singleProfile.setQuery(this.query());
163
163
  sel.setSingle(singleProfile);
@@ -170,7 +170,7 @@ export class SingleProfileSource implements ProfileSource {
170
170
  req.setMode(QueryRequest.Mode.MODE_SINGLE_UNSPECIFIED);
171
171
  const singleQueryRequest = new SingleProfile();
172
172
  const ts = new Timestamp();
173
- ts.fromDate(moment(this.time).toDate());
173
+ ts.fromDate(new Date(this.time));
174
174
  singleQueryRequest.setTime(ts);
175
175
  singleQueryRequest.setQuery(this.query());
176
176
  req.setSingle(singleQueryRequest);
@@ -201,7 +201,7 @@ export class SingleProfileSource implements ProfileSource {
201
201
  </button>
202
202
  ))}
203
203
  </p>
204
- <p>{moment(this.time).utc().format(timeFormat)}</p>
204
+ <p>{formatDate(this.time, timeFormat)}</p>
205
205
  </>
206
206
  );
207
207
  }
@@ -215,7 +215,7 @@ export class SingleProfileSource implements ProfileSource {
215
215
  toString(): string {
216
216
  return `single profile of type ${this.profileName()} with labels ${this.stringLabels().join(
217
217
  ', '
218
- )} collected at ${moment(this.time).utc().format(timeFormat)}`;
218
+ )} collected at ${formatDate(this.time, timeFormat)}`;
219
219
  }
220
220
  }
221
221
 
@@ -275,11 +275,11 @@ export class MergedProfileSource implements ProfileSource {
275
275
  const mergeProfile = new MergeProfile();
276
276
 
277
277
  const startTs = new Timestamp();
278
- startTs.fromDate(moment(this.from).toDate());
278
+ startTs.fromDate(new Date(this.from));
279
279
  mergeProfile.setStart(startTs);
280
280
 
281
281
  const endTs = new Timestamp();
282
- endTs.fromDate(moment(this.to).toDate());
282
+ endTs.fromDate(new Date(this.to));
283
283
  mergeProfile.setEnd(endTs);
284
284
 
285
285
  mergeProfile.setQuery(this.query);
@@ -296,11 +296,11 @@ export class MergedProfileSource implements ProfileSource {
296
296
  const mergeQueryRequest = new MergeProfile();
297
297
 
298
298
  const startTs = new Timestamp();
299
- startTs.fromDate(moment(this.from).toDate());
299
+ startTs.fromDate(new Date(this.from));
300
300
  mergeQueryRequest.setStart(startTs);
301
301
 
302
302
  const endTs = new Timestamp();
303
- endTs.fromDate(moment(this.to).toDate());
303
+ endTs.fromDate(new Date(this.to));
304
304
  mergeQueryRequest.setEnd(endTs);
305
305
 
306
306
  mergeQueryRequest.setQuery(this.query);
@@ -313,15 +313,16 @@ export class MergedProfileSource implements ProfileSource {
313
313
  Describe(): JSX.Element {
314
314
  return (
315
315
  <a>
316
- Merge of "{this.query}" from {moment(this.from).utc().format(timeFormat)} to{' '}
317
- {moment(this.to).utc().format(timeFormat)}
316
+ Merge of "{this.query}" from {formatDate(this.from, timeFormat)} to{' '}
317
+ {formatDate(this.to, timeFormat)}
318
318
  </a>
319
319
  );
320
320
  }
321
321
 
322
322
  toString(): string {
323
- return `merged profiles of query "${this.query}" from ${moment(this.from)
324
- .utc()
325
- .format(timeFormat)} to ${moment(this.to).utc().format(timeFormat)}`;
323
+ return `merged profiles of query "${this.query}" from ${formatDate(
324
+ this.from,
325
+ timeFormat
326
+ )} to ${formatDate(this.to, timeFormat)}`;
326
327
  }
327
328
  }
@@ -2,12 +2,12 @@ import React, {useEffect, useState} from 'react';
2
2
  import {CalcWidth} from '@parca/dynamicsize';
3
3
  import {parseParams} from '@parca/functions';
4
4
  import {QueryRequest, QueryResponse, QueryServiceClient, ServiceError} from '@parca/client';
5
- import Button from '@parca/web/src/components/ui/Button';
5
+ import {Button} from '@parca/components';
6
6
  import * as parca_query_v1alpha1_query_pb from '@parca/client/src/parca/query/v1alpha1/query_pb';
7
7
 
8
8
  import ProfileIcicleGraph from './ProfileIcicleGraph';
9
9
  import {ProfileSource} from './ProfileSource';
10
- import Card from '../../../app/web/src/components/ui/Card';
10
+ import {Card} from '@parca/components';
11
11
  import TopTable from './TopTable';
12
12
 
13
13
  import './ProfileView.styles.css';
@@ -21,6 +21,7 @@ interface ProfileViewProps {
21
21
  }
22
22
 
23
23
  export interface IQueryResult {
24
+ isLoading: boolean;
24
25
  response: QueryResponse | null;
25
26
  error: ServiceError | null;
26
27
  }
@@ -39,16 +40,22 @@ export const useQuery = (
39
40
  profileSource: ProfileSource
40
41
  ): IQueryResult => {
41
42
  const [result, setResult] = useState<IQueryResult>({
43
+ isLoading: false,
42
44
  response: null,
43
45
  error: null,
44
46
  });
45
47
 
46
48
  useEffect(() => {
49
+ setResult({
50
+ ...result,
51
+ isLoading: true,
52
+ });
47
53
  const req = profileSource.QueryRequest();
48
54
  req.setReportType(QueryRequest.ReportType.REPORT_TYPE_FLAMEGRAPH_UNSPECIFIED);
49
55
 
50
56
  client.query(req, (error: ServiceError | null, responseMessage: QueryResponse | null) => {
51
57
  setResult({
58
+ isLoading: false,
52
59
  response: responseMessage,
53
60
  error: error,
54
61
  });
@@ -66,14 +73,24 @@ export const ProfileView = ({
66
73
  const router = parseParams(window.location.search);
67
74
  const currentViewFromURL = router.currentProfileView as string;
68
75
  const [curPath, setCurPath] = useState<string[]>([]);
69
- const {response, error} = useQuery(queryClient, profileSource);
76
+ const [isLoaderVisible, setIsLoaderVisible] = useState<boolean>(false);
77
+ const {isLoading, response, error} = useQuery(queryClient, profileSource);
70
78
  const [currentView, setCurrentView] = useState<string | undefined>(currentViewFromURL);
71
79
 
72
- if (error != null) {
73
- return <div className="p-10 flex justify-center">An error occurred: {error.message}</div>;
74
- }
80
+ useEffect(() => {
81
+ let showLoaderTimeout;
82
+ if (isLoading && !isLoaderVisible) {
83
+ // if the request takes longer than half a second, show the loading icon
84
+ showLoaderTimeout = setTimeout(() => {
85
+ setIsLoaderVisible(true);
86
+ }, 500);
87
+ } else {
88
+ setIsLoaderVisible(false);
89
+ }
90
+ return () => clearTimeout(showLoaderTimeout);
91
+ }, [isLoading]);
75
92
 
76
- if (response == null) {
93
+ if (isLoaderVisible) {
77
94
  return (
78
95
  <div
79
96
  style={{
@@ -109,6 +126,10 @@ export const ProfileView = ({
109
126
  );
110
127
  }
111
128
 
129
+ if (error) {
130
+ return <div className="p-10 flex justify-center">An error occurred: {error.message}</div>;
131
+ }
132
+
112
133
  const downloadPProf = (e: React.MouseEvent<HTMLElement>) => {
113
134
  e.preventDefault();
114
135
 
@@ -215,7 +236,7 @@ export const ProfileView = ({
215
236
  <ProfileIcicleGraph
216
237
  curPath={curPath}
217
238
  setNewCurPath={setNewCurPath}
218
- graph={response.getFlamegraph()?.toObject()}
239
+ graph={response?.getFlamegraph()?.toObject()}
219
240
  />
220
241
  </CalcWidth>
221
242
  </div>
@@ -238,7 +259,7 @@ export const ProfileView = ({
238
259
  <ProfileIcicleGraph
239
260
  curPath={curPath}
240
261
  setNewCurPath={setNewCurPath}
241
- graph={response.getFlamegraph()?.toObject()}
262
+ graph={response?.getFlamegraph()?.toObject()}
242
263
  />
243
264
  </CalcWidth>
244
265
  </div>