@parca/profile 0.16.123 → 0.16.125-alpha.1
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 +20 -0
- package/dist/DiffLegend/index.d.ts +3 -0
- package/dist/DiffLegend/index.js +62 -0
- package/dist/MetricsGraph/MetricsTooltip/index.js +1 -1
- package/dist/MetricsGraph/index.d.ts +1 -0
- package/dist/MetricsGraph/index.js +6 -4
- package/dist/ProfileShareButton/ResultBox.d.ts +7 -0
- package/dist/ProfileShareButton/ResultBox.js +46 -0
- package/dist/ProfileShareButton/index.d.ts +9 -0
- package/dist/ProfileShareButton/index.js +119 -0
- package/dist/TopTable/index.js +1 -1
- package/dist/components/ProfileShareButton/ResultBox.js +3 -0
- package/package.json +6 -6
- package/src/MetricsGraph/MetricsTooltip/index.tsx +7 -1
- package/src/MetricsGraph/index.tsx +7 -4
- package/src/TopTable/index.tsx +1 -1
- package/src/components/ProfileShareButton/ResultBox.tsx +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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.125-alpha.1](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.124...@parca/profile@0.16.125-alpha.1) (2023-02-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.16.125-alpha.0](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.124...@parca/profile@0.16.125-alpha.0) (2023-02-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @parca/profile
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.16.124](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.123...@parca/profile@0.16.124) (2023-02-22)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @parca/profile
|
|
25
|
+
|
|
6
26
|
## [0.16.123](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.122...@parca/profile@0.16.123) (2023-02-22)
|
|
7
27
|
|
|
8
28
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
// Copyright 2022 The Parca Authors
|
|
14
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
// you may not use this file except in compliance with the License.
|
|
16
|
+
// You may obtain a copy of the License at
|
|
17
|
+
//
|
|
18
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
//
|
|
20
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
21
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
+
// See the License for the specific language governing permissions and
|
|
24
|
+
// limitations under the License.
|
|
25
|
+
import { Fragment, useState } from 'react';
|
|
26
|
+
import { Popover, Transition } from '@headlessui/react';
|
|
27
|
+
import { usePopper } from 'react-popper';
|
|
28
|
+
import { selectDarkMode, useAppSelector } from '@parca/store';
|
|
29
|
+
import { getIncreasedSpanColor, getNewSpanColor, getReducedSpanColor } from '@parca/utilities';
|
|
30
|
+
var transparencyValues = [-100, -80, -60, -40, -20, 0, 20, 40, 60, 80, 100];
|
|
31
|
+
var DiffLegendBar = function (_a) {
|
|
32
|
+
var onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave;
|
|
33
|
+
var isDarkMode = useAppSelector(selectDarkMode);
|
|
34
|
+
return (_jsx("div", __assign({ className: "flex items-center m-2" }, { children: transparencyValues.map(function (value) {
|
|
35
|
+
var valueAsPercentage = value / 100;
|
|
36
|
+
var absoluteValue = Math.abs(valueAsPercentage);
|
|
37
|
+
return (_jsx("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: "w-8 h-4", style: {
|
|
38
|
+
backgroundColor: absoluteValue === 0
|
|
39
|
+
? getNewSpanColor(isDarkMode)
|
|
40
|
+
: valueAsPercentage > 0
|
|
41
|
+
? getIncreasedSpanColor(absoluteValue, isDarkMode)
|
|
42
|
+
: getReducedSpanColor(absoluteValue, isDarkMode),
|
|
43
|
+
} }, valueAsPercentage));
|
|
44
|
+
}) })));
|
|
45
|
+
};
|
|
46
|
+
var DiffLegend = function () {
|
|
47
|
+
var _a = useState(false), showLegendTooltip = _a[0], setShowLegendTooltip = _a[1];
|
|
48
|
+
var _b = useState(null), popperElement = _b[0], setPopperElement = _b[1];
|
|
49
|
+
var _c = useState(null), referenceElement = _c[0], setReferenceElement = _c[1];
|
|
50
|
+
var _d = usePopper(referenceElement, popperElement, {
|
|
51
|
+
placement: 'auto-start',
|
|
52
|
+
strategy: 'absolute',
|
|
53
|
+
}), styles = _d.styles, attributes = _d.attributes;
|
|
54
|
+
var handleMouseEnter = function () {
|
|
55
|
+
setShowLegendTooltip(true);
|
|
56
|
+
};
|
|
57
|
+
var handleMouseLeave = function () {
|
|
58
|
+
setShowLegendTooltip(false);
|
|
59
|
+
};
|
|
60
|
+
return (_jsxs("div", __assign({ className: "mt-1 mb-2" }, { children: [_jsxs("div", __assign({ ref: setReferenceElement, className: "flex items-center justify-center" }, { children: [_jsx("span", { children: "Better" }), _jsx(DiffLegendBar, { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }), _jsx("span", { children: "Worse" })] })), _jsx(Popover, __assign({ className: "relative" }, { children: function () { return (_jsx(Transition, __assign({ show: showLegendTooltip, as: Fragment, enter: "transition ease-out duration-200", enterFrom: "opacity-0 translate-y-1", enterTo: "opacity-100 translate-y-0", leave: "transition ease-in duration-150", leaveFrom: "opacity-100 translate-y-0", leaveTo: "opacity-0 translate-y-1" }, { children: _jsx(Popover.Panel, __assign({ ref: setPopperElement, style: styles.popper }, attributes.popper, { children: _jsx("div", __assign({ className: "overflow-hidden rounded-lg shadow-lg ring-1 ring-black ring-opacity-5" }, { children: _jsxs("div", __assign({ className: "p-4 bg-gray-50 dark:bg-gray-800" }, { children: [_jsx("div", { className: "flex items-center justify-center" }), _jsx("span", __assign({ className: "block text-sm text-gray-500 dark:text-gray-50" }, { children: "This is a differential icicle graph, where a purple-colored node means unchanged, and the darker the red, the worse the node got, and the darker the green, the better the node got." }))] })) })) })) }))); } }))] })));
|
|
61
|
+
};
|
|
62
|
+
export default DiffLegend;
|
|
@@ -98,7 +98,7 @@ var MetricsTooltip = function (_a) {
|
|
|
98
98
|
}, [x, y, contextElement, update]);
|
|
99
99
|
var nameLabel = highlighted === null || highlighted === void 0 ? void 0 : highlighted.labels.find(function (e) { return e.name === '__name__'; });
|
|
100
100
|
var highlightedNameLabel = nameLabel !== undefined ? nameLabel : { name: '', value: '' };
|
|
101
|
-
return (_jsx("div", __assign({ ref: setPopperElement, style: styles.popper }, attributes.popper, { className: "z-10" }, { children: _jsx("div", __assign({ className: "flex max-w-md" }, { children: _jsx("div", __assign({ className: "m-auto" }, { children: _jsx("div", __assign({ className: "border-gray-300 dark:border-gray-500 bg-gray-50 dark:bg-gray-900 rounded-lg p-3 shadow-lg opacity-90", style: { borderWidth: 1 } }, { children: _jsx("div", __assign({ className: "flex flex-row" }, { children: _jsxs("div", __assign({ className: "ml-2 mr-6" }, { children: [_jsx("span", __assign({ className: "font-semibold" }, { children: highlightedNameLabel.value })), _jsx("span", __assign({ className: "block text-gray-700 dark:text-gray-300 my-2" }, { children: _jsx("table", __assign({ className: "table-auto" }, { children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Value" })), _jsx("td", __assign({ className: "w-3/4" }, { children: valueFormatter(highlighted.
|
|
101
|
+
return (_jsx("div", __assign({ ref: setPopperElement, style: styles.popper }, attributes.popper, { className: "z-10" }, { children: _jsx("div", __assign({ className: "flex max-w-md" }, { children: _jsx("div", __assign({ className: "m-auto" }, { children: _jsx("div", __assign({ className: "border-gray-300 dark:border-gray-500 bg-gray-50 dark:bg-gray-900 rounded-lg p-3 shadow-lg opacity-90", style: { borderWidth: 1 } }, { children: _jsx("div", __assign({ className: "flex flex-row" }, { children: _jsxs("div", __assign({ className: "ml-2 mr-6" }, { children: [_jsx("span", __assign({ className: "font-semibold" }, { children: highlightedNameLabel.value })), _jsx("span", __assign({ className: "block text-gray-700 dark:text-gray-300 my-2" }, { children: _jsx("table", __assign({ className: "table-auto" }, { children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Value" })), _jsx("td", __assign({ className: "w-3/4" }, { children: valueFormatter(highlighted.valuePerSecond, sampleUnit, 5) }))] }), _jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "Total" })), _jsx("td", __assign({ className: "w-3/4" }, { children: valueFormatter(highlighted.value, sampleUnit, 2) }))] }), _jsxs("tr", { children: [_jsx("td", __assign({ className: "w-1/4" }, { children: "At" })), _jsx("td", __assign({ className: "w-3/4" }, { children: formatDate(highlighted.timestamp, timeFormat) }))] })] }) })) })), _jsx("span", __assign({ className: "block text-gray-500 my-2" }, { children: highlighted.labels
|
|
102
102
|
.filter(function (label) { return label.name !== '__name__'; })
|
|
103
103
|
.map(function (label) {
|
|
104
104
|
return (_jsx("button", __assign({ type: "button", className: "inline-block rounded-lg text-gray-700 bg-gray-200 dark:bg-gray-700 dark:text-gray-400 px-2 py-1 text-xs font-bold mr-3", onClick: function () { return onLabelClick(label.name, label.value); } }, { children: _jsx(TextWithTooltip, { text: "".concat(label.name, "=\"").concat(label.value, "\""), maxTextLength: 37, id: "tooltip-".concat(label.name, "-").concat(label.value) }) }), label.name));
|
|
@@ -68,9 +68,9 @@ export var RawMetricsGraph = function (_a) {
|
|
|
68
68
|
agg.push({
|
|
69
69
|
metric: s.labelset.labels,
|
|
70
70
|
values: s.samples.reduce(function (agg, d) {
|
|
71
|
-
if (d.timestamp !== undefined && d.
|
|
71
|
+
if (d.timestamp !== undefined && d.valuePerSecond !== undefined) {
|
|
72
72
|
var t = (+d.timestamp.seconds * 1e9 + d.timestamp.nanos) / 1e6; // https://github.com/microsoft/TypeScript/issues/5710#issuecomment-157886246
|
|
73
|
-
agg.push([t, parseFloat(d.value)]);
|
|
73
|
+
agg.push([t, d.valuePerSecond, parseFloat(d.value)]);
|
|
74
74
|
}
|
|
75
75
|
return agg;
|
|
76
76
|
}, []),
|
|
@@ -122,7 +122,8 @@ export var RawMetricsGraph = function (_a) {
|
|
|
122
122
|
seriesIndex: closestSeriesIndex,
|
|
123
123
|
labels: series[closestSeriesIndex].metric,
|
|
124
124
|
timestamp: point[0],
|
|
125
|
-
|
|
125
|
+
valuePerSecond: point[1],
|
|
126
|
+
value: point[2],
|
|
126
127
|
x: xScale(point[0]),
|
|
127
128
|
y: yScale(point[1]),
|
|
128
129
|
};
|
|
@@ -228,7 +229,8 @@ export var RawMetricsGraph = function (_a) {
|
|
|
228
229
|
labels: [],
|
|
229
230
|
seriesIndex: seriesIndex,
|
|
230
231
|
timestamp: sample[0],
|
|
231
|
-
|
|
232
|
+
valuePerSecond: sample[1],
|
|
233
|
+
value: sample[2],
|
|
232
234
|
x: xScale(sample[0]),
|
|
233
235
|
y: yScale(sample[1]),
|
|
234
236
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
// Copyright 2022 The Parca Authors
|
|
14
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
// you may not use this file except in compliance with the License.
|
|
16
|
+
// You may obtain a copy of the License at
|
|
17
|
+
//
|
|
18
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
//
|
|
20
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
21
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
+
// See the License for the specific language governing permissions and
|
|
24
|
+
// limitations under the License.
|
|
25
|
+
import { useState } from 'react';
|
|
26
|
+
import { Icon } from '@iconify/react';
|
|
27
|
+
import cx from 'classnames';
|
|
28
|
+
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
29
|
+
import { Button } from '@parca/components';
|
|
30
|
+
var timeoutHandle = null;
|
|
31
|
+
var ResultBox = function (_a) {
|
|
32
|
+
var _b;
|
|
33
|
+
var value = _a.value, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
34
|
+
var _d = useState(false), isCopied = _d[0], setIsCopied = _d[1];
|
|
35
|
+
var onCopy = function () {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
setIsCopied(true);
|
|
38
|
+
(_b = (_a = window.document) === null || _a === void 0 ? void 0 : _a.activeElement) === null || _b === void 0 ? void 0 : _b.blur();
|
|
39
|
+
if (timeoutHandle != null) {
|
|
40
|
+
clearTimeout(timeoutHandle);
|
|
41
|
+
}
|
|
42
|
+
timeoutHandle = setTimeout(function () { return setIsCopied(false); }, 3000);
|
|
43
|
+
};
|
|
44
|
+
return (_jsxs("div", __assign({ className: cx('flex flex-row w-full', (_b = {}, _b[className] = (className === null || className === void 0 ? void 0 : className.length) > 0, _b)) }, { children: [_jsx("span", __assign({ className: "flex justify-center items-center border border-r-0 w-16 rounded-l" }, { children: _jsx(Icon, { icon: "ant-design:link-outlined" }) })), _jsx("input", { type: "text", className: "border text-sm bg-inherit w-full px-1 py-2 flex-grow", value: value, readOnly: true }), _jsx(CopyToClipboard, __assign({ text: value, onCopy: onCopy }, { children: _jsx(Button, __assign({ variant: "link", className: "border border-l-0 w-fit whitespace-nowrap p-4 items-center !text-indigo-600 dark:!text-indigo-400 rounded-none rounded-r" }, { children: isCopied ? 'Copied!' : 'Copy Link' })) }))] })));
|
|
45
|
+
};
|
|
46
|
+
export default ResultBox;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { QueryRequest, QueryServiceClient } from '@parca/client';
|
|
3
|
+
interface Props {
|
|
4
|
+
queryRequest: QueryRequest;
|
|
5
|
+
queryClient: QueryServiceClient;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const ProfileShareButton: ({ queryRequest, queryClient, disabled }: Props) => JSX.Element;
|
|
9
|
+
export default ProfileShareButton;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
+
// Copyright 2022 The Parca Authors
|
|
50
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
51
|
+
// you may not use this file except in compliance with the License.
|
|
52
|
+
// You may obtain a copy of the License at
|
|
53
|
+
//
|
|
54
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
+
//
|
|
56
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
57
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
58
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
+
// See the License for the specific language governing permissions and
|
|
60
|
+
// limitations under the License.
|
|
61
|
+
import { useState } from 'react';
|
|
62
|
+
import { Icon } from '@iconify/react';
|
|
63
|
+
import { Button, Modal, useGrpcMetadata } from '@parca/components';
|
|
64
|
+
import ResultBox from './ResultBox';
|
|
65
|
+
var ProfileShareModal = function (_a) {
|
|
66
|
+
var isOpen = _a.isOpen, closeModal = _a.closeModal, queryRequest = _a.queryRequest, queryClient = _a.queryClient;
|
|
67
|
+
var _b = useState(false), isShared = _b[0], setIsShared = _b[1];
|
|
68
|
+
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
69
|
+
var _d = useState(''), error = _d[0], setError = _d[1];
|
|
70
|
+
var _e = useState(''), description = _e[0], setDescription = _e[1];
|
|
71
|
+
var _f = useState(''), sharedLink = _f[0], setSharedLink = _f[1];
|
|
72
|
+
var metadata = useGrpcMetadata();
|
|
73
|
+
var isFormDataValid = function () { return true; };
|
|
74
|
+
var handleSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var response, err_1;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
_a.trys.push([0, 2, , 3]);
|
|
80
|
+
setLoading(true);
|
|
81
|
+
return [4 /*yield*/, queryClient.shareProfile({ queryRequest: queryRequest, description: description }, { meta: metadata })];
|
|
82
|
+
case 1:
|
|
83
|
+
response = (_a.sent()).response;
|
|
84
|
+
setSharedLink(response.link);
|
|
85
|
+
setLoading(false);
|
|
86
|
+
setIsShared(true);
|
|
87
|
+
return [3 /*break*/, 3];
|
|
88
|
+
case 2:
|
|
89
|
+
err_1 = _a.sent();
|
|
90
|
+
if (err_1 instanceof Error) {
|
|
91
|
+
console.error(err_1);
|
|
92
|
+
setLoading(false);
|
|
93
|
+
// https://github.com/microsoft/TypeScript/issues/38347
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
95
|
+
setError(err_1.toString());
|
|
96
|
+
}
|
|
97
|
+
return [3 /*break*/, 3];
|
|
98
|
+
case 3: return [2 /*return*/];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}); };
|
|
102
|
+
var onClose = function () {
|
|
103
|
+
setLoading(false);
|
|
104
|
+
setError('');
|
|
105
|
+
setDescription('');
|
|
106
|
+
setIsShared(false);
|
|
107
|
+
closeModal();
|
|
108
|
+
};
|
|
109
|
+
return (_jsx(Modal, __assign({ isOpen: isOpen, closeModal: onClose, title: "Share Profile", className: "w-[420px]" }, { children: _jsxs("form", __assign({ className: "py-2" }, { children: [_jsx("p", __assign({ className: "text-sm text-gray-500 dark:text-gray-300" }, { children: "Note: Shared profiles can be accessed by anyone with the link, even from people outside your organisation." })), !isShared || (error === null || error === void 0 ? void 0 : error.length) > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", __assign({ className: "text-sm text-gray-500 dark:text-gray-300 mt-3 mb-2" }, { children: "Enter a description (optional)" })), _jsx("textarea", { className: "border w-full text-gray-500 dark:text-gray-300 bg-inherit text-sm px-2 py-2", value: description, onChange: function (e) { return setDescription(e.target.value); } }), _jsx(Button, __assign({ className: "w-fit mt-4", onClick: function (e) {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
void handleSubmit();
|
|
112
|
+
}, disabled: loading || !isFormDataValid(), type: "submit" }, { children: loading ? 'Sharing' : 'Share' })), error !== '' ? _jsx("p", { children: "Something went wrong please try again" }) : null] })) : (_jsxs(_Fragment, { children: [_jsx(ResultBox, { value: sharedLink, className: "mt-4" }), _jsx("div", __assign({ className: "flex justify-center mt-8" }, { children: _jsx(Button, __assign({ variant: "neutral", className: "w-fit", onClick: onClose }, { children: "Close" })) }))] }))] })) })));
|
|
113
|
+
};
|
|
114
|
+
var ProfileShareButton = function (_a) {
|
|
115
|
+
var queryRequest = _a.queryRequest, queryClient = _a.queryClient, _b = _a.disabled, disabled = _b === void 0 ? false : _b;
|
|
116
|
+
var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
|
|
117
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, __assign({ color: "neutral", className: "w-fit", onClick: function () { return setIsOpen(true); }, disabled: disabled }, { children: _jsx(Icon, { icon: "ei:share-apple", width: 20 }) })), _jsx(ProfileShareModal, { isOpen: isOpen, closeModal: function () { return setIsOpen(false); }, queryRequest: queryRequest, queryClient: queryClient })] }));
|
|
118
|
+
};
|
|
119
|
+
export default ProfileShareButton;
|
package/dist/TopTable/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var addPlusSign = function (num) {
|
|
|
50
50
|
export var TopTable = React.memo(function TopTable(_a) {
|
|
51
51
|
var _b;
|
|
52
52
|
var top = _a.data, unit = _a.sampleUnit, navigateTo = _a.navigateTo, loading = _a.loading, currentSearchString = _a.currentSearchString, setActionButtons = _a.setActionButtons;
|
|
53
|
-
var router = parseParams(window.location.search);
|
|
53
|
+
var router = parseParams(window === null || window === void 0 ? void 0 : window.location.search);
|
|
54
54
|
var rawDashboardItems = useURLState({ param: 'dashboard_items' })[0];
|
|
55
55
|
var rawcompareMode = useURLState({ param: 'compare_a' })[0];
|
|
56
56
|
var compareMode = rawcompareMode === undefined ? false : rawcompareMode === 'true';
|
|
@@ -34,6 +34,9 @@ var ResultBox = function (_a) {
|
|
|
34
34
|
var _d = useState(false), isCopied = _d[0], setIsCopied = _d[1];
|
|
35
35
|
var onCopy = function () {
|
|
36
36
|
var _a, _b;
|
|
37
|
+
if (typeof window === 'undefined') {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
37
40
|
setIsCopied(true);
|
|
38
41
|
(_b = (_a = window.document) === null || _a === void 0 ? void 0 : _a.activeElement) === null || _b === void 0 ? void 0 : _b.blur();
|
|
39
42
|
if (timeoutHandle != null) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.125-alpha.1",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@parca/client": "^0.16.
|
|
7
|
-
"@parca/components": "^0.16.
|
|
6
|
+
"@parca/client": "^0.16.64",
|
|
7
|
+
"@parca/components": "^0.16.104-alpha.1",
|
|
8
8
|
"@parca/dynamicsize": "^0.16.53",
|
|
9
|
-
"@parca/functions": "^0.16.
|
|
9
|
+
"@parca/functions": "^0.16.65-alpha.1",
|
|
10
10
|
"@parca/parser": "^0.16.54",
|
|
11
|
-
"@parca/store": "^0.16.
|
|
11
|
+
"@parca/store": "^0.16.61-alpha.1",
|
|
12
12
|
"@types/react-beautiful-dnd": "^13.1.3",
|
|
13
13
|
"d3": "7.8.2",
|
|
14
14
|
"d3-scale": "^4.0.2",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"access": "public",
|
|
46
46
|
"registry": "https://registry.npmjs.org/"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "c5f3a609889d2d36e7ffd449866e599a1311c1d0"
|
|
49
49
|
}
|
|
@@ -119,7 +119,13 @@ const MetricsTooltip = ({
|
|
|
119
119
|
<tr>
|
|
120
120
|
<td className="w-1/4">Value</td>
|
|
121
121
|
<td className="w-3/4">
|
|
122
|
-
{valueFormatter(highlighted.
|
|
122
|
+
{valueFormatter(highlighted.valuePerSecond, sampleUnit, 5)}
|
|
123
|
+
</td>
|
|
124
|
+
</tr>
|
|
125
|
+
<tr>
|
|
126
|
+
<td className="w-1/4">Total</td>
|
|
127
|
+
<td className="w-3/4">
|
|
128
|
+
{valueFormatter(highlighted.value, sampleUnit, 2)}
|
|
123
129
|
</td>
|
|
124
130
|
</tr>
|
|
125
131
|
<tr>
|
|
@@ -49,6 +49,7 @@ export interface HighlightedSeries {
|
|
|
49
49
|
labels: Label[];
|
|
50
50
|
timestamp: number;
|
|
51
51
|
value: number;
|
|
52
|
+
valuePerSecond: number;
|
|
52
53
|
x: number;
|
|
53
54
|
y: number;
|
|
54
55
|
}
|
|
@@ -134,9 +135,9 @@ export const RawMetricsGraph = ({
|
|
|
134
135
|
agg.push({
|
|
135
136
|
metric: s.labelset.labels,
|
|
136
137
|
values: s.samples.reduce<number[][]>(function (agg: number[][], d: MetricsSample) {
|
|
137
|
-
if (d.timestamp !== undefined && d.
|
|
138
|
+
if (d.timestamp !== undefined && d.valuePerSecond !== undefined) {
|
|
138
139
|
const t = (+d.timestamp.seconds * 1e9 + d.timestamp.nanos) / 1e6; // https://github.com/microsoft/TypeScript/issues/5710#issuecomment-157886246
|
|
139
|
-
agg.push([t, parseFloat(d.value)]);
|
|
140
|
+
agg.push([t, d.valuePerSecond, parseFloat(d.value)]);
|
|
140
141
|
}
|
|
141
142
|
return agg;
|
|
142
143
|
}, []),
|
|
@@ -202,7 +203,8 @@ export const RawMetricsGraph = ({
|
|
|
202
203
|
seriesIndex: closestSeriesIndex,
|
|
203
204
|
labels: series[closestSeriesIndex].metric,
|
|
204
205
|
timestamp: point[0],
|
|
205
|
-
|
|
206
|
+
valuePerSecond: point[1],
|
|
207
|
+
value: point[2],
|
|
206
208
|
x: xScale(point[0]),
|
|
207
209
|
y: yScale(point[1]),
|
|
208
210
|
};
|
|
@@ -325,7 +327,8 @@ export const RawMetricsGraph = ({
|
|
|
325
327
|
labels: [],
|
|
326
328
|
seriesIndex,
|
|
327
329
|
timestamp: sample[0],
|
|
328
|
-
|
|
330
|
+
valuePerSecond: sample[1],
|
|
331
|
+
value: sample[2],
|
|
329
332
|
x: xScale(sample[0]),
|
|
330
333
|
y: yScale(sample[1]),
|
|
331
334
|
};
|
package/src/TopTable/index.tsx
CHANGED
|
@@ -70,7 +70,7 @@ export const TopTable = React.memo(function TopTable({
|
|
|
70
70
|
currentSearchString,
|
|
71
71
|
setActionButtons,
|
|
72
72
|
}: TopTableProps): JSX.Element {
|
|
73
|
-
const router = parseParams(window
|
|
73
|
+
const router = parseParams(window?.location.search);
|
|
74
74
|
const [rawDashboardItems] = useURLState({param: 'dashboard_items'});
|
|
75
75
|
const [rawcompareMode] = useURLState({param: 'compare_a'});
|
|
76
76
|
|
|
@@ -30,6 +30,10 @@ const ResultBox = ({value, className = ''}: Props): JSX.Element => {
|
|
|
30
30
|
const [isCopied, setIsCopied] = useState<boolean>(false);
|
|
31
31
|
|
|
32
32
|
const onCopy = (): void => {
|
|
33
|
+
if (typeof window === 'undefined') {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
33
37
|
setIsCopied(true);
|
|
34
38
|
(window.document?.activeElement as HTMLElement)?.blur();
|
|
35
39
|
if (timeoutHandle != null) {
|