@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.
Files changed (182) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
  9. package/dist/MatchersInput/SuggestionItem.js +91 -12
  10. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  11. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  12. package/dist/MatchersInput/SuggestionsList.js +371 -157
  13. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  15. package/dist/MatchersInput/index.js +308 -115
  16. package/dist/MetricsCircle/index.js +39 -3
  17. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  18. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  19. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  20. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  21. package/dist/MetricsGraph/index.js +552 -203
  22. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  23. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  24. package/dist/MetricsSeries/index.js +70 -7
  25. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  26. package/dist/PreSelectedMatchers/index.js +249 -102
  27. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
  29. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  30. package/dist/ProfileExplorer/index.js +183 -32
  31. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  33. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  34. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  35. package/dist/ProfileFlameChart/index.js +260 -126
  36. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
  37. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  38. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  39. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  56. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  57. package/dist/ProfileFlameGraph/index.js +322 -147
  58. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  59. package/dist/ProfileMetricsGraph/index.js +515 -256
  60. package/dist/ProfileSelector/CompareButton.js +132 -12
  61. package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
  62. package/dist/ProfileSelector/index.d.ts +1 -1
  63. package/dist/ProfileSelector/index.d.ts.map +1 -1
  64. package/dist/ProfileSelector/index.js +734 -142
  65. package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
  66. package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
  67. package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
  68. package/dist/ProfileSource.js +230 -163
  69. package/dist/ProfileTypeSelector/index.js +214 -125
  70. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  71. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
  72. package/dist/ProfileView/components/ColorStackLegend.js +182 -54
  73. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  74. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  75. package/dist/ProfileView/components/DiffLegend.js +172 -29
  76. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  77. package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
  78. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  79. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  80. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  81. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
  82. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  83. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  84. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  85. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  86. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
  87. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  88. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
  89. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  90. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  91. package/dist/ProfileView/components/ViewSelector/index.js +186 -82
  92. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  93. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  94. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  95. package/dist/ProfileView/context/DashboardContext.js +74 -26
  96. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  97. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  98. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  99. package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
  100. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  101. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
  102. package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
  103. package/dist/ProfileView/index.js +383 -45
  104. package/dist/ProfileView/types/visualization.js +1 -13
  105. package/dist/ProfileView/utils/colorUtils.js +8 -7
  106. package/dist/ProfileViewWithData.js +319 -225
  107. package/dist/QueryControls/index.js +418 -47
  108. package/dist/Sandwich/components/CalleesSection.js +54 -4
  109. package/dist/Sandwich/components/CallersSection.js +97 -27
  110. package/dist/Sandwich/components/TableSection.js +77 -4
  111. package/dist/Sandwich/index.js +125 -12
  112. package/dist/Sandwich/utils/processRowData.js +48 -39
  113. package/dist/SelectWithRefresh/index.js +102 -28
  114. package/dist/SimpleMatchers/Select.js +520 -187
  115. package/dist/SimpleMatchers/index.js +590 -288
  116. package/dist/SourceView/Highlighter.js +230 -70
  117. package/dist/SourceView/LineNo.js +72 -17
  118. package/dist/SourceView/index.js +177 -101
  119. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  120. package/dist/SourceView/lang-detector/index.js +28 -14
  121. package/dist/SourceView/useSelectedLineRange.js +72 -20
  122. package/dist/Table/ColorCell.js +42 -1
  123. package/dist/Table/ColumnsVisibility.js +114 -6
  124. package/dist/Table/MoreDropdown.js +107 -21
  125. package/dist/Table/TableContextMenu.js +144 -134
  126. package/dist/Table/TableContextMenuWrapper.js +59 -14
  127. package/dist/Table/hooks/useColorManagement.js +58 -16
  128. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  129. package/dist/Table/hooks/useTableConfiguration.js +323 -167
  130. package/dist/Table/index.js +217 -123
  131. package/dist/Table/utils/functions.js +169 -144
  132. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  133. package/dist/TimelineGuide/index.js +209 -16
  134. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  135. package/dist/TopTable/index.js +325 -121
  136. package/dist/contexts/LabelsQueryProvider.js +94 -32
  137. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  138. package/dist/contexts/utils.js +37 -15
  139. package/dist/hooks/urlParsers.js +27 -15
  140. package/dist/hooks/useColorBy.js +47 -10
  141. package/dist/hooks/useCompareModeMeta.js +112 -62
  142. package/dist/hooks/useDashboardItems.js +52 -11
  143. package/dist/hooks/useLabels.js +295 -52
  144. package/dist/hooks/useQueryState.d.ts +1 -1
  145. package/dist/hooks/useQueryState.d.ts.map +1 -1
  146. package/dist/hooks/useQueryState.js +375 -329
  147. package/dist/index.js +11 -6
  148. package/dist/testdata/fg-diff.json +3750 -0
  149. package/dist/testdata/fg-simple.json +1879 -0
  150. package/dist/testdata/link_data.json +56 -0
  151. package/dist/testdata/tabular.json +30 -0
  152. package/dist/testdata/test_flamegraph.json +26846 -0
  153. package/dist/testdata/test_graph.json +53 -0
  154. package/dist/useDelayedLoader.js +32 -18
  155. package/dist/useGrpcQuery/index.js +71 -11
  156. package/dist/useHasProfileData.js +90 -12
  157. package/dist/useQuery.js +205 -64
  158. package/dist/useSumBy.d.ts.map +1 -1
  159. package/dist/useSumBy.js +294 -138
  160. package/dist/utils.js +62 -30
  161. package/package.json +9 -9
  162. package/src/GraphTooltipArrow/index.tsx +3 -0
  163. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  164. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  165. package/src/MatchersInput/index.tsx +1 -1
  166. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  167. package/src/PreSelectedMatchers/index.tsx +3 -0
  168. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
  169. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
  170. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  171. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  172. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  173. package/src/ProfileSelector/index.tsx +31 -9
  174. package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
  175. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
  176. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  177. package/src/Table/hooks/useTableConfiguration.tsx +7 -13
  178. package/src/hooks/useQueryState.ts +18 -3
  179. package/src/useDelayedLoader.ts +10 -10
  180. package/src/useSumBy.ts +12 -18
  181. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  182. 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
- import { BINARY_FEATURE_TYPES, EVERYTHING_ELSE, FILENAMES_FEATURE_TYPES, } from '@parca/store';
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, } from './index';
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
- const labelsOnly = table.getChild(FIELD_LABELS_ONLY)?.get(row);
20
- const depth = table.getChild(FIELD_DEPTH)?.get(row) ?? 0;
21
- if (depth === 1 && labelsOnly !== null && labelsOnly) {
22
- return getLabelSet(table, row);
23
- }
24
- const functionName = arrowToString(table.getChild(FIELD_FUNCTION_NAME)?.get(row));
25
- if (functionName !== null && functionName !== '') {
26
- return functionName;
27
- }
28
- let mappingString = '';
29
- if (showBinaryName) {
30
- const mappingFile = table.getChild(FIELD_MAPPING_FILE)?.get(row) ?? '';
31
- const binary = getLastItem(mappingFile ?? undefined);
32
- if (binary != null)
33
- mappingString = `[${binary}]`;
34
- }
35
- const addressBigInt = table.getChild(FIELD_LOCATION_ADDRESS)?.get(row);
36
- const address = hexifyAddress(addressBigInt);
37
- const fallback = `${mappingString}${address}`;
38
- return fallback === '' ? '<unknown>' : fallback;
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 const extractFeature = (mapping) => {
41
- if (mapping != null && mapping !== '') {
42
- return { name: mapping, type: BINARY_FEATURE_TYPES.Binary };
43
- }
44
- return { name: EVERYTHING_ELSE, type: BINARY_FEATURE_TYPES.Misc };
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 const extractFilenameFeature = (filename) => {
47
- if (filename != null && filename !== '') {
48
- return { name: filename, type: FILENAMES_FEATURE_TYPES.Filename };
49
- }
50
- return { name: EVERYTHING_ELSE, type: FILENAMES_FEATURE_TYPES.Misc };
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 const getTextForCumulative = (hoveringNodeCumulative, totalUnfiltered, total, unit) => {
53
- const filtered = totalUnfiltered > total
54
- ? ` / ${(100 * divide(hoveringNodeCumulative, total)).toFixed(2)}% of filtered`
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 const getTextForCumulativePerSecond = (hoveringNodeCumulative, unit) => {
60
- return `${valueFormatter(hoveringNodeCumulative, unit === 'nanoseconds' ? 'CPU Cores' : unit, 5)}/s`;
77
+ export var getTextForCumulativePerSecond = function getTextForCumulativePerSecond(hoveringNodeCumulative, unit) {
78
+ return "".concat(valueFormatter(hoveringNodeCumulative, unit === 'nanoseconds' ? 'CPU Cores' : unit, 5), "/s");
61
79
  };
62
- export const arrowToString = (buffer) => {
63
- if (buffer == null || typeof buffer === 'string') {
64
- return buffer;
65
- }
66
- if (ArrayBuffer.isView(buffer)) {
67
- return new TextDecoder().decode(buffer);
68
- }
69
- return '';
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 const boundsFromProfileSource = (profileSource) => {
72
- if (profileSource === undefined) {
73
- return [0n, 1n];
74
- }
75
- if (!(profileSource instanceof MergedProfileSource)) {
76
- return [0n, 1n];
77
- }
78
- const request = profileSource.QueryRequest();
79
- if (request.options.oneofKind !== 'merge' ||
80
- request.options.merge.start === undefined ||
81
- request.options.merge.end === undefined) {
82
- return [0n, 1n];
83
- }
84
- const start = request.options.merge.start.seconds * 1000000000n + BigInt(request.options.merge.start.nanos);
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 const getCurrentPathFrameData = (table, row) => {
89
- const functionName = arrowToString(table.getChild(FIELD_FUNCTION_NAME)?.get(row));
90
- const systemName = arrowToString(table.getChild(FIELD_FUNCTION_NAME)?.get(row));
91
- const fileName = arrowToString(table.getChild(FIELD_MAPPING_FILE)?.get(row));
92
- const lineNumber = table.getChild(FIELD_FUNCTION_START_LINE)?.get(row) ?? 0n;
93
- const addressBigInt = table.getChild(FIELD_LOCATION_ADDRESS)?.get(row);
94
- const address = hexifyAddress(addressBigInt);
95
- const inlined = table.getChild(FIELD_INLINED)?.get(row);
96
- const labelsOnly = table.getChild(FIELD_LABELS_ONLY)?.get(row);
97
- const depth = table.getChild(FIELD_DEPTH)?.get(row) ?? 0;
98
- let labels;
99
- if (depth === 1 && labelsOnly !== null && labelsOnly) {
100
- labels = getLabelSet(table, row);
101
- }
102
- return {
103
- functionName: functionName ?? '',
104
- systemName: systemName ?? '',
105
- fileName: fileName ?? '',
106
- lineNumber: Number(lineNumber),
107
- address,
108
- inlined: inlined ?? false,
109
- labels: labels ?? undefined,
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
- const labelPrefix = 'labels.';
114
- const labelColumnNames = table.schema.fields.filter(field => field.name.startsWith(labelPrefix));
115
- return labelColumnNames
116
- .map((field, i) => [
117
- labelColumnNames[i].name.slice(labelPrefix.length),
118
- arrowToString(table.getChild(field.name)?.get(row)) ?? '',
119
- ])
120
- .filter(value => value[1] !== '')
121
- .map(([k, v]) => `${k}="${v}"`)
122
- .join(', ');
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
- const a = getCurrentPathFrameData(table, row);
126
- return (a.functionName === b.functionName &&
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
- if (depthColumn === null)
136
- return 0;
137
- let max = 0;
138
- for (const val of depthColumn) {
139
- const numVal = Number(val);
140
- if (numVal > max)
141
- max = numVal;
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
- return max;
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
+ });