@parca/profile 0.19.140 → 0.19.143
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 +9 -1
- package/dist/GraphTooltipArrow/Content.js +224 -30
- package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
- package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/index.js +86 -56
- package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
- package/dist/MatchersInput/SuggestionItem.js +91 -12
- package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
- package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
- package/dist/MatchersInput/SuggestionsList.js +371 -157
- package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
- package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
- package/dist/MatchersInput/index.js +308 -115
- package/dist/MetricsCircle/index.js +39 -3
- package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
- package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
- package/dist/MetricsGraph/index.js +552 -203
- package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
- package/dist/MetricsGraph/utils/colorMapping.js +24 -17
- package/dist/MetricsSeries/index.js +70 -7
- package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
- package/dist/PreSelectedMatchers/index.js +249 -102
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
- package/dist/ProfileExplorer/index.js +183 -32
- package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
- package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
- package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.js +260 -126
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
- package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
- package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
- package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
- package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
- package/dist/ProfileFlameGraph/index.js +322 -147
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.js +515 -256
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
- package/dist/ProfileSelector/index.d.ts +1 -1
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +734 -142
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
- package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
- package/dist/ProfileSource.js +230 -163
- package/dist/ProfileTypeSelector/index.js +214 -125
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
- package/dist/ProfileView/components/ColorStackLegend.js +182 -54
- package/dist/ProfileView/components/DashboardItems/index.js +87 -28
- package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
- package/dist/ProfileView/components/DiffLegend.js +172 -29
- package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
- package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
- package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
- package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
- package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
- package/dist/ProfileView/components/ShareButton/index.js +352 -62
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.js +186 -82
- package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
- package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
- package/dist/ProfileView/components/VisualizationPanel.js +185 -8
- package/dist/ProfileView/context/DashboardContext.js +74 -26
- package/dist/ProfileView/context/ProfileViewContext.js +56 -15
- package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
- package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
- package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
- package/dist/ProfileView/index.js +383 -45
- package/dist/ProfileView/types/visualization.js +1 -13
- package/dist/ProfileView/utils/colorUtils.js +8 -7
- package/dist/ProfileViewWithData.js +319 -225
- package/dist/QueryControls/index.js +418 -47
- package/dist/Sandwich/components/CalleesSection.js +54 -4
- package/dist/Sandwich/components/CallersSection.js +97 -27
- package/dist/Sandwich/components/TableSection.js +77 -4
- package/dist/Sandwich/index.js +125 -12
- package/dist/Sandwich/utils/processRowData.js +48 -39
- package/dist/SelectWithRefresh/index.js +102 -28
- package/dist/SimpleMatchers/Select.js +520 -187
- package/dist/SimpleMatchers/index.js +590 -288
- package/dist/SourceView/Highlighter.js +230 -70
- package/dist/SourceView/LineNo.js +72 -17
- package/dist/SourceView/index.js +177 -101
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.js +72 -20
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.js +107 -21
- package/dist/Table/TableContextMenu.js +144 -134
- package/dist/Table/TableContextMenuWrapper.js +59 -14
- package/dist/Table/hooks/useColorManagement.js +58 -16
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +323 -167
- package/dist/Table/index.js +217 -123
- package/dist/Table/utils/functions.js +169 -144
- package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
- package/dist/TimelineGuide/index.js +209 -16
- package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/dist/TopTable/index.js +325 -121
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/urlParsers.js +27 -15
- package/dist/hooks/useColorBy.js +47 -10
- package/dist/hooks/useCompareModeMeta.js +112 -62
- package/dist/hooks/useDashboardItems.js +52 -11
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +1 -1
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +375 -329
- package/dist/index.js +11 -6
- package/dist/testdata/fg-diff.json +3750 -0
- package/dist/testdata/fg-simple.json +1879 -0
- package/dist/testdata/link_data.json +56 -0
- package/dist/testdata/tabular.json +30 -0
- package/dist/testdata/test_flamegraph.json +26846 -0
- package/dist/testdata/test_graph.json +53 -0
- package/dist/useDelayedLoader.js +32 -18
- package/dist/useGrpcQuery/index.js +71 -11
- package/dist/useHasProfileData.js +90 -12
- package/dist/useQuery.js +205 -64
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -9
- package/src/GraphTooltipArrow/index.tsx +3 -0
- package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
- package/src/MatchersInput/SuggestionsList.tsx +11 -10
- package/src/MatchersInput/index.tsx +1 -1
- package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
- package/src/PreSelectedMatchers/index.tsx +3 -0
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
- package/src/ProfileSelector/index.tsx +31 -9
- package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/Table/hooks/useTableConfiguration.tsx +7 -13
- package/src/hooks/useQueryState.ts +18 -3
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +12 -18
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/useQueryState.test.js +0 -868
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1
8
|
// Copyright 2022 The Parca Authors
|
|
2
9
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
10
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,135 +17,151 @@
|
|
|
10
17
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
18
|
// See the License for the specific language governing permissions and
|
|
12
19
|
// limitations under the License.
|
|
13
|
-
|
|
20
|
+
|
|
21
|
+
import { BINARY_FEATURE_TYPES, EVERYTHING_ELSE, FILENAMES_FEATURE_TYPES } from '@parca/store';
|
|
14
22
|
import { divide, getLastItem, valueFormatter } from '@parca/utilities';
|
|
15
23
|
import { MergedProfileSource } from '../../ProfileSource';
|
|
16
24
|
import { hexifyAddress } from '../../utils';
|
|
17
|
-
import { FIELD_DEPTH, FIELD_FUNCTION_NAME, FIELD_FUNCTION_START_LINE, FIELD_INLINED, FIELD_LABELS_ONLY, FIELD_LOCATION_ADDRESS, FIELD_MAPPING_FILE
|
|
25
|
+
import { FIELD_DEPTH, FIELD_FUNCTION_NAME, FIELD_FUNCTION_START_LINE, FIELD_INLINED, FIELD_LABELS_ONLY, FIELD_LOCATION_ADDRESS, FIELD_MAPPING_FILE } from './index';
|
|
18
26
|
export function nodeLabel(table, row, showBinaryName) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
var _table$getChild, _table$getChild$get, _table$getChild2, _table$getChild3, _table$getChild5;
|
|
28
|
+
var labelsOnly = (_table$getChild = table.getChild(FIELD_LABELS_ONLY)) === null || _table$getChild === void 0 ? void 0 : _table$getChild.get(row);
|
|
29
|
+
var depth = (_table$getChild$get = (_table$getChild2 = table.getChild(FIELD_DEPTH)) === null || _table$getChild2 === void 0 ? void 0 : _table$getChild2.get(row)) !== null && _table$getChild$get !== void 0 ? _table$getChild$get : 0;
|
|
30
|
+
if (depth === 1 && labelsOnly !== null && labelsOnly) {
|
|
31
|
+
return getLabelSet(table, row);
|
|
32
|
+
}
|
|
33
|
+
var functionName = arrowToString((_table$getChild3 = table.getChild(FIELD_FUNCTION_NAME)) === null || _table$getChild3 === void 0 ? void 0 : _table$getChild3.get(row));
|
|
34
|
+
if (functionName !== null && functionName !== '') {
|
|
35
|
+
return functionName;
|
|
36
|
+
}
|
|
37
|
+
var mappingString = '';
|
|
38
|
+
if (showBinaryName) {
|
|
39
|
+
var _table$getChild$get2, _table$getChild4;
|
|
40
|
+
var mappingFile = (_table$getChild$get2 = (_table$getChild4 = table.getChild(FIELD_MAPPING_FILE)) === null || _table$getChild4 === void 0 ? void 0 : _table$getChild4.get(row)) !== null && _table$getChild$get2 !== void 0 ? _table$getChild$get2 : '';
|
|
41
|
+
var binary = getLastItem(mappingFile !== null && mappingFile !== void 0 ? mappingFile : undefined);
|
|
42
|
+
if (binary != null) mappingString = "[".concat(binary, "]");
|
|
43
|
+
}
|
|
44
|
+
var addressBigInt = (_table$getChild5 = table.getChild(FIELD_LOCATION_ADDRESS)) === null || _table$getChild5 === void 0 ? void 0 : _table$getChild5.get(row);
|
|
45
|
+
var address = hexifyAddress(addressBigInt);
|
|
46
|
+
var fallback = "".concat(mappingString).concat(address);
|
|
47
|
+
return fallback === '' ? '<unknown>' : fallback;
|
|
39
48
|
}
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
export var extractFeature = function extractFeature(mapping) {
|
|
50
|
+
if (mapping != null && mapping !== '') {
|
|
51
|
+
return {
|
|
52
|
+
name: mapping,
|
|
53
|
+
type: BINARY_FEATURE_TYPES.Binary
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
name: EVERYTHING_ELSE,
|
|
58
|
+
type: BINARY_FEATURE_TYPES.Misc
|
|
59
|
+
};
|
|
45
60
|
};
|
|
46
|
-
export
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
export var extractFilenameFeature = function extractFilenameFeature(filename) {
|
|
62
|
+
if (filename != null && filename !== '') {
|
|
63
|
+
return {
|
|
64
|
+
name: filename,
|
|
65
|
+
type: FILENAMES_FEATURE_TYPES.Filename
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
name: EVERYTHING_ELSE,
|
|
70
|
+
type: FILENAMES_FEATURE_TYPES.Misc
|
|
71
|
+
};
|
|
51
72
|
};
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
: '';
|
|
56
|
-
return `${valueFormatter(hoveringNodeCumulative, unit, 2)}
|
|
57
|
-
(${(100 * divide(hoveringNodeCumulative, totalUnfiltered)).toFixed(2)}%${filtered})`;
|
|
73
|
+
export var getTextForCumulative = function getTextForCumulative(hoveringNodeCumulative, totalUnfiltered, total, unit) {
|
|
74
|
+
var filtered = totalUnfiltered > total ? " / ".concat((100 * divide(hoveringNodeCumulative, total)).toFixed(2), "% of filtered") : '';
|
|
75
|
+
return "".concat(valueFormatter(hoveringNodeCumulative, unit, 2), "\n (").concat((100 * divide(hoveringNodeCumulative, totalUnfiltered)).toFixed(2), "%").concat(filtered, ")");
|
|
58
76
|
};
|
|
59
|
-
export
|
|
60
|
-
|
|
77
|
+
export var getTextForCumulativePerSecond = function getTextForCumulativePerSecond(hoveringNodeCumulative, unit) {
|
|
78
|
+
return "".concat(valueFormatter(hoveringNodeCumulative, unit === 'nanoseconds' ? 'CPU Cores' : unit, 5), "/s");
|
|
61
79
|
};
|
|
62
|
-
export
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
export var arrowToString = function arrowToString(buffer) {
|
|
81
|
+
if (buffer == null || typeof buffer === 'string') {
|
|
82
|
+
return buffer;
|
|
83
|
+
}
|
|
84
|
+
if (ArrayBuffer.isView(buffer)) {
|
|
85
|
+
return new TextDecoder().decode(buffer);
|
|
86
|
+
}
|
|
87
|
+
return '';
|
|
70
88
|
};
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const end = request.options.merge.end.seconds * 1000000000n + BigInt(request.options.merge.end.nanos);
|
|
86
|
-
return [start, end];
|
|
89
|
+
export var boundsFromProfileSource = function boundsFromProfileSource(profileSource) {
|
|
90
|
+
if (profileSource === undefined) {
|
|
91
|
+
return [0n, 1n];
|
|
92
|
+
}
|
|
93
|
+
if (!(profileSource instanceof MergedProfileSource)) {
|
|
94
|
+
return [0n, 1n];
|
|
95
|
+
}
|
|
96
|
+
var request = profileSource.QueryRequest();
|
|
97
|
+
if (request.options.oneofKind !== 'merge' || request.options.merge.start === undefined || request.options.merge.end === undefined) {
|
|
98
|
+
return [0n, 1n];
|
|
99
|
+
}
|
|
100
|
+
var start = request.options.merge.start.seconds * 1000000000n + BigInt(request.options.merge.start.nanos);
|
|
101
|
+
var end = request.options.merge.end.seconds * 1000000000n + BigInt(request.options.merge.end.nanos);
|
|
102
|
+
return [start, end];
|
|
87
103
|
};
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
export var getCurrentPathFrameData = function getCurrentPathFrameData(table, row) {
|
|
105
|
+
var _table$getChild6, _table$getChild7, _table$getChild8, _table$getChild$get3, _table$getChild9, _table$getChild0, _table$getChild1, _table$getChild10, _table$getChild$get4, _table$getChild11;
|
|
106
|
+
var functionName = arrowToString((_table$getChild6 = table.getChild(FIELD_FUNCTION_NAME)) === null || _table$getChild6 === void 0 ? void 0 : _table$getChild6.get(row));
|
|
107
|
+
var systemName = arrowToString((_table$getChild7 = table.getChild(FIELD_FUNCTION_NAME)) === null || _table$getChild7 === void 0 ? void 0 : _table$getChild7.get(row));
|
|
108
|
+
var fileName = arrowToString((_table$getChild8 = table.getChild(FIELD_MAPPING_FILE)) === null || _table$getChild8 === void 0 ? void 0 : _table$getChild8.get(row));
|
|
109
|
+
var lineNumber = (_table$getChild$get3 = (_table$getChild9 = table.getChild(FIELD_FUNCTION_START_LINE)) === null || _table$getChild9 === void 0 ? void 0 : _table$getChild9.get(row)) !== null && _table$getChild$get3 !== void 0 ? _table$getChild$get3 : 0n;
|
|
110
|
+
var addressBigInt = (_table$getChild0 = table.getChild(FIELD_LOCATION_ADDRESS)) === null || _table$getChild0 === void 0 ? void 0 : _table$getChild0.get(row);
|
|
111
|
+
var address = hexifyAddress(addressBigInt);
|
|
112
|
+
var inlined = (_table$getChild1 = table.getChild(FIELD_INLINED)) === null || _table$getChild1 === void 0 ? void 0 : _table$getChild1.get(row);
|
|
113
|
+
var labelsOnly = (_table$getChild10 = table.getChild(FIELD_LABELS_ONLY)) === null || _table$getChild10 === void 0 ? void 0 : _table$getChild10.get(row);
|
|
114
|
+
var depth = (_table$getChild$get4 = (_table$getChild11 = table.getChild(FIELD_DEPTH)) === null || _table$getChild11 === void 0 ? void 0 : _table$getChild11.get(row)) !== null && _table$getChild$get4 !== void 0 ? _table$getChild$get4 : 0;
|
|
115
|
+
var labels;
|
|
116
|
+
if (depth === 1 && labelsOnly !== null && labelsOnly) {
|
|
117
|
+
labels = getLabelSet(table, row);
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
functionName: functionName !== null && functionName !== void 0 ? functionName : '',
|
|
121
|
+
systemName: systemName !== null && systemName !== void 0 ? systemName : '',
|
|
122
|
+
fileName: fileName !== null && fileName !== void 0 ? fileName : '',
|
|
123
|
+
lineNumber: Number(lineNumber),
|
|
124
|
+
address: address,
|
|
125
|
+
inlined: inlined !== null && inlined !== void 0 ? inlined : false,
|
|
126
|
+
labels: labels !== null && labels !== void 0 ? labels : undefined
|
|
127
|
+
};
|
|
111
128
|
};
|
|
112
129
|
function getLabelSet(table, row) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
])
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
var labelPrefix = 'labels.';
|
|
131
|
+
var labelColumnNames = table.schema.fields.filter(function (field) {
|
|
132
|
+
return field.name.startsWith(labelPrefix);
|
|
133
|
+
});
|
|
134
|
+
return labelColumnNames.map(function (field, i) {
|
|
135
|
+
var _arrowToString, _table$getChild12;
|
|
136
|
+
return [labelColumnNames[i].name.slice(labelPrefix.length), (_arrowToString = arrowToString((_table$getChild12 = table.getChild(field.name)) === null || _table$getChild12 === void 0 ? void 0 : _table$getChild12.get(row))) !== null && _arrowToString !== void 0 ? _arrowToString : ''];
|
|
137
|
+
}).filter(function (value) {
|
|
138
|
+
return value[1] !== '';
|
|
139
|
+
}).map(function (_ref) {
|
|
140
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
141
|
+
k = _ref2[0],
|
|
142
|
+
v = _ref2[1];
|
|
143
|
+
return "".concat(k, "=\"").concat(v, "\"");
|
|
144
|
+
}).join(', ');
|
|
123
145
|
}
|
|
124
146
|
export function isCurrentPathFrameMatch(table, row, b) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
a.systemName === b.systemName &&
|
|
128
|
-
a.fileName === b.fileName &&
|
|
129
|
-
a.lineNumber === b.lineNumber &&
|
|
130
|
-
a.address === b.address &&
|
|
131
|
-
a.inlined === b.inlined &&
|
|
132
|
-
a.labels === b.labels);
|
|
147
|
+
var a = getCurrentPathFrameData(table, row);
|
|
148
|
+
return a.functionName === b.functionName && a.systemName === b.systemName && a.fileName === b.fileName && a.lineNumber === b.lineNumber && a.address === b.address && a.inlined === b.inlined && a.labels === b.labels;
|
|
133
149
|
}
|
|
134
150
|
export function getMaxDepth(depthColumn) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
151
|
+
if (depthColumn === null) return 0;
|
|
152
|
+
var max = 0;
|
|
153
|
+
var _iterator = _createForOfIteratorHelper(depthColumn),
|
|
154
|
+
_step;
|
|
155
|
+
try {
|
|
156
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
157
|
+
var val = _step.value;
|
|
158
|
+
var numVal = Number(val);
|
|
159
|
+
if (numVal > max) max = numVal;
|
|
142
160
|
}
|
|
143
|
-
|
|
144
|
-
|
|
161
|
+
} catch (err) {
|
|
162
|
+
_iterator.e(err);
|
|
163
|
+
} finally {
|
|
164
|
+
_iterator.f();
|
|
165
|
+
}
|
|
166
|
+
return max;
|
|
167
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Copyright 2022 The Parca Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
|
|
14
|
+
const {GrpcWebFetchTransport} = require('@protobuf-ts/grpcweb-transport');
|
|
15
|
+
const client = require('@parca/client');
|
|
16
|
+
const fs = require('fs-extra');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
// const {fileURLToPath} = require('url');
|
|
19
|
+
const fetch = require('node-fetch');
|
|
20
|
+
|
|
21
|
+
globalThis.fetch = fetch;
|
|
22
|
+
globalThis.Headers = fetch.Headers;
|
|
23
|
+
const DIR_NAME = __dirname; // path.dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
|
|
25
|
+
const apiEndpoint = 'https://demo.parca.dev';
|
|
26
|
+
|
|
27
|
+
const queryClient = new client.QueryServiceClient(
|
|
28
|
+
new GrpcWebFetchTransport({
|
|
29
|
+
baseUrl: `${apiEndpoint}/api`,
|
|
30
|
+
})
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const populateDataIfNeeded = async (from, filename) => {
|
|
34
|
+
const filePath = path.join(DIR_NAME, filename);
|
|
35
|
+
if (Object.keys(await readFile(filePath)).length > 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const {response} = await queryClient.query({
|
|
39
|
+
options: {
|
|
40
|
+
oneofKind: 'merge',
|
|
41
|
+
merge: {
|
|
42
|
+
start: client.Timestamp.fromDate(from),
|
|
43
|
+
end: client.Timestamp.fromDate(new Date()),
|
|
44
|
+
query: 'parca_agent_cpu:samples:count:cpu:nanoseconds:delta{container="parca"}',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
reportType: client.QueryRequest_ReportType.FLAMEGRAPH_TABLE,
|
|
48
|
+
mode: client.QueryRequest_Mode.MERGE,
|
|
49
|
+
});
|
|
50
|
+
if (response.report.oneofKind !== 'flamegraph') {
|
|
51
|
+
throw new Error('Expected flamegraph report');
|
|
52
|
+
}
|
|
53
|
+
await writeToFile(response.report.flamegraph, filePath);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const writeToFile = async (data, filename) => {
|
|
57
|
+
await fs.createFile(filename);
|
|
58
|
+
return await fs.writeFile(filename, JSON.stringify(data));
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const readFile = async filename => {
|
|
62
|
+
try {
|
|
63
|
+
return await fs.readJSON(filename);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const run = async () => {
|
|
70
|
+
await Promise.all([
|
|
71
|
+
populateDataIfNeeded(new Date(new Date().getTime() - 1000 * 60), 'parca-1m.json'),
|
|
72
|
+
populateDataIfNeeded(new Date(new Date().getTime() - 1000 * 60 * 10), 'parca-10m.json'),
|
|
73
|
+
populateDataIfNeeded(new Date(new Date().getTime() - 1000 * 60 * 20), 'parca-20m.json'),
|
|
74
|
+
]);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
run()
|
|
78
|
+
.then(() => {
|
|
79
|
+
console.log('done');
|
|
80
|
+
process.exit(0);
|
|
81
|
+
})
|
|
82
|
+
.catch(err => {
|
|
83
|
+
console.error('Error:', err);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|