@parca/profile 0.19.140 → 0.19.142

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 (253) hide show
  1. package/CHANGELOG.md +5 -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.d.ts.map +1 -1
  9. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
  10. package/dist/MatchersInput/SuggestionItem.js +91 -12
  11. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  12. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  13. package/dist/MatchersInput/SuggestionsList.js +371 -157
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  15. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  16. package/dist/MatchersInput/index.js +308 -115
  17. package/dist/MetricsCircle/index.js +39 -3
  18. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  19. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  20. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  21. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  22. package/dist/MetricsGraph/index.js +552 -203
  23. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  24. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  25. package/dist/MetricsSeries/index.js +70 -7
  26. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  27. package/dist/PreSelectedMatchers/index.js +249 -102
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  29. package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
  30. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  31. package/dist/ProfileExplorer/index.js +183 -32
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  33. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  34. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
  35. package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
  36. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  37. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  38. package/dist/ProfileFlameChart/index.d.ts.map +1 -1
  39. package/dist/ProfileFlameChart/index.js +267 -129
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  56. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  57. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  58. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  59. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  60. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  61. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  62. package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
  63. package/dist/ProfileFlameGraph/index.js +324 -150
  64. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  65. package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
  66. package/dist/ProfileMetricsGraph/index.js +519 -258
  67. package/dist/ProfileSelector/CompareButton.js +132 -12
  68. package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
  69. package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
  70. package/dist/ProfileSelector/index.d.ts.map +1 -1
  71. package/dist/ProfileSelector/index.js +727 -141
  72. package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
  73. package/dist/ProfileSource.js +230 -163
  74. package/dist/ProfileTypeSelector/index.js +214 -125
  75. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  76. package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
  77. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
  78. package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
  79. package/dist/ProfileView/components/ColorStackLegend.js +185 -55
  80. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  81. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  82. package/dist/ProfileView/components/DiffLegend.js +172 -29
  83. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  84. package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
  85. package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
  86. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  87. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  88. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  89. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
  90. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
  91. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
  92. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  93. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  94. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  95. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  96. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
  97. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  98. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
  99. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
  100. package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
  101. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  102. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  103. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  104. package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
  105. package/dist/ProfileView/components/ViewSelector/index.js +212 -86
  106. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  107. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  108. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  109. package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
  110. package/dist/ProfileView/context/DashboardContext.js +85 -29
  111. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  112. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  113. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  114. package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
  115. package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
  116. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
  117. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  118. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
  119. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
  120. package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
  121. package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
  122. package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
  123. package/dist/ProfileView/index.js +383 -45
  124. package/dist/ProfileView/types/visualization.js +1 -13
  125. package/dist/ProfileView/utils/colorUtils.js +8 -7
  126. package/dist/ProfileViewWithData.d.ts.map +1 -1
  127. package/dist/ProfileViewWithData.js +332 -228
  128. package/dist/QueryControls/index.js +418 -47
  129. package/dist/Sandwich/components/CalleesSection.js +54 -4
  130. package/dist/Sandwich/components/CallersSection.js +97 -27
  131. package/dist/Sandwich/components/TableSection.js +77 -4
  132. package/dist/Sandwich/index.d.ts.map +1 -1
  133. package/dist/Sandwich/index.js +126 -14
  134. package/dist/Sandwich/utils/processRowData.js +48 -39
  135. package/dist/SelectWithRefresh/index.js +102 -28
  136. package/dist/SimpleMatchers/Select.js +520 -187
  137. package/dist/SimpleMatchers/index.js +590 -288
  138. package/dist/SourceView/Highlighter.js +230 -70
  139. package/dist/SourceView/LineNo.js +72 -17
  140. package/dist/SourceView/index.d.ts.map +1 -1
  141. package/dist/SourceView/index.js +178 -104
  142. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  143. package/dist/SourceView/lang-detector/index.js +28 -14
  144. package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
  145. package/dist/SourceView/useSelectedLineRange.js +99 -23
  146. package/dist/Table/ColorCell.js +42 -1
  147. package/dist/Table/ColumnsVisibility.js +114 -6
  148. package/dist/Table/MoreDropdown.d.ts.map +1 -1
  149. package/dist/Table/MoreDropdown.js +122 -25
  150. package/dist/Table/TableContextMenu.d.ts.map +1 -1
  151. package/dist/Table/TableContextMenu.js +151 -137
  152. package/dist/Table/TableContextMenuWrapper.js +59 -14
  153. package/dist/Table/hooks/useColorManagement.js +58 -16
  154. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  155. package/dist/Table/hooks/useTableConfiguration.js +333 -169
  156. package/dist/Table/index.d.ts.map +1 -1
  157. package/dist/Table/index.js +222 -128
  158. package/dist/Table/utils/functions.js +169 -144
  159. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  160. package/dist/TimelineGuide/index.js +209 -16
  161. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  162. package/dist/TopTable/index.d.ts.map +1 -1
  163. package/dist/TopTable/index.js +342 -123
  164. package/dist/contexts/LabelsQueryProvider.js +94 -32
  165. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  166. package/dist/contexts/utils.js +37 -15
  167. package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
  168. package/dist/hooks/useCompareModeMeta.js +158 -64
  169. package/dist/hooks/useLabels.js +295 -52
  170. package/dist/hooks/useQueryState.d.ts +3 -3
  171. package/dist/hooks/useQueryState.d.ts.map +1 -1
  172. package/dist/hooks/useQueryState.js +373 -332
  173. package/dist/index.d.ts +2 -3
  174. package/dist/index.d.ts.map +1 -1
  175. package/dist/index.js +22 -8
  176. package/dist/testdata/fg-diff.json +3750 -0
  177. package/dist/testdata/fg-simple.json +1879 -0
  178. package/dist/testdata/link_data.json +56 -0
  179. package/dist/testdata/tabular.json +30 -0
  180. package/dist/testdata/test_flamegraph.json +26846 -0
  181. package/dist/testdata/test_graph.json +53 -0
  182. package/dist/useDelayedLoader.js +32 -18
  183. package/dist/useGrpcQuery/index.js +71 -11
  184. package/dist/useHasProfileData.js +90 -12
  185. package/dist/useQuery.js +205 -64
  186. package/dist/useSumBy.d.ts +1 -1
  187. package/dist/useSumBy.d.ts.map +1 -1
  188. package/dist/useSumBy.js +294 -138
  189. package/dist/utils.js +62 -30
  190. package/package.json +9 -10
  191. package/src/GraphTooltipArrow/index.tsx +3 -0
  192. package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
  193. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  194. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  195. package/src/MatchersInput/index.tsx +1 -1
  196. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  197. package/src/PreSelectedMatchers/index.tsx +3 -0
  198. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
  199. package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
  200. package/src/ProfileFlameChart/index.tsx +28 -21
  201. package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
  202. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
  203. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  204. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  205. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  206. package/src/ProfileFlameGraph/index.tsx +9 -6
  207. package/src/ProfileMetricsGraph/index.tsx +8 -6
  208. package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
  209. package/src/ProfileSelector/index.tsx +61 -39
  210. package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
  211. package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
  212. package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
  213. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
  214. package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
  215. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
  216. package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
  217. package/src/ProfileView/components/Toolbars/index.tsx +3 -3
  218. package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
  219. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  220. package/src/ProfileView/context/DashboardContext.tsx +6 -6
  221. package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
  222. package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
  223. package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
  224. package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
  225. package/src/ProfileViewWithData.tsx +35 -29
  226. package/src/Sandwich/index.tsx +3 -4
  227. package/src/SourceView/index.tsx +2 -4
  228. package/src/SourceView/useSelectedLineRange.ts +19 -34
  229. package/src/Table/MoreDropdown.tsx +11 -9
  230. package/src/Table/TableContextMenu.tsx +13 -10
  231. package/src/Table/hooks/useTableConfiguration.tsx +11 -16
  232. package/src/Table/index.tsx +21 -12
  233. package/src/TopTable/index.tsx +4 -3
  234. package/src/hooks/useCompareModeMeta.ts +91 -61
  235. package/src/hooks/useQueryState.test.tsx +345 -275
  236. package/src/hooks/useQueryState.ts +118 -136
  237. package/src/index.tsx +15 -16
  238. package/src/useDelayedLoader.ts +10 -10
  239. package/src/useSumBy.ts +15 -21
  240. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  241. package/dist/hooks/urlParsers.d.ts +0 -18
  242. package/dist/hooks/urlParsers.d.ts.map +0 -1
  243. package/dist/hooks/urlParsers.js +0 -32
  244. package/dist/hooks/useColorBy.d.ts +0 -5
  245. package/dist/hooks/useColorBy.d.ts.map +0 -1
  246. package/dist/hooks/useColorBy.js +0 -26
  247. package/dist/hooks/useDashboardItems.d.ts +0 -5
  248. package/dist/hooks/useDashboardItems.d.ts.map +0 -1
  249. package/dist/hooks/useDashboardItems.js +0 -27
  250. package/dist/hooks/useQueryState.test.js +0 -868
  251. package/src/hooks/urlParsers.ts +0 -38
  252. package/src/hooks/useColorBy.ts +0 -42
  253. package/src/hooks/useDashboardItems.ts +0 -46
@@ -1,3 +1,10 @@
1
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
4
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
5
+ 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; } } }; }
6
+ 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; } }
7
+ 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; }
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,70 +17,122 @@
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.
20
+
13
21
  // Determine which label keys have all-numeric values across every label set.
14
- const getNumericKeys = (labelSets) => {
15
- const numericKeys = new Set();
16
- if (labelSets.length === 0)
17
- return numericKeys;
18
- const keyCandidates = new Set(labelSets[0].labels.map(l => l.name));
19
- for (const key of keyCandidates) {
20
- const allNumeric = labelSets.every(ls => {
21
- const label = ls.labels.find(l => l.name === key);
22
- return label != null && label.value !== '' && !isNaN(Number(label.value));
22
+ var getNumericKeys = function getNumericKeys(labelSets) {
23
+ var numericKeys = new Set();
24
+ if (labelSets.length === 0) return numericKeys;
25
+ var keyCandidates = new Set(labelSets[0].labels.map(function (l) {
26
+ return l.name;
27
+ }));
28
+ var _iterator = _createForOfIteratorHelper(keyCandidates),
29
+ _step;
30
+ try {
31
+ var _loop = function _loop() {
32
+ var key = _step.value;
33
+ var allNumeric = labelSets.every(function (ls) {
34
+ var label = ls.labels.find(function (l) {
35
+ return l.name === key;
23
36
  });
24
- if (allNumeric)
25
- numericKeys.add(key);
37
+ return label != null && label.value !== '' && !isNaN(Number(label.value));
38
+ });
39
+ if (allNumeric) numericKeys.add(key);
40
+ };
41
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
42
+ _loop();
26
43
  }
27
- return numericKeys;
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
48
+ }
49
+ return numericKeys;
28
50
  };
51
+
29
52
  // Get key order: text keys first (sorted), then numeric keys (sorted).
30
- const getSortedKeys = (labelSets, numericKeys) => {
31
- const allKeys = new Set();
32
- for (const ls of labelSets) {
33
- for (const l of ls.labels)
34
- allKeys.add(l.name);
53
+ var getSortedKeys = function getSortedKeys(labelSets, numericKeys) {
54
+ var allKeys = new Set();
55
+ var _iterator2 = _createForOfIteratorHelper(labelSets),
56
+ _step2;
57
+ try {
58
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
59
+ var ls = _step2.value;
60
+ var _iterator3 = _createForOfIteratorHelper(ls.labels),
61
+ _step3;
62
+ try {
63
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
64
+ var l = _step3.value;
65
+ allKeys.add(l.name);
66
+ }
67
+ } catch (err) {
68
+ _iterator3.e(err);
69
+ } finally {
70
+ _iterator3.f();
71
+ }
35
72
  }
36
- return [...allKeys]
37
- .filter(k => !numericKeys.has(k))
38
- .sort()
39
- .concat([...numericKeys].sort());
73
+ } catch (err) {
74
+ _iterator2.e(err);
75
+ } finally {
76
+ _iterator2.f();
77
+ }
78
+ return _toConsumableArray(allKeys).filter(function (k) {
79
+ return !numericKeys.has(k);
80
+ }).sort().concat(_toConsumableArray(numericKeys).sort());
40
81
  };
82
+
41
83
  // Format a LabelSet as a string with keys ordered: text first, then numeric.
42
- export const labelSetToString = (labelSet, keyOrder) => {
43
- if (labelSet === undefined)
44
- return '{}';
45
- const labels = keyOrder != null
46
- ? keyOrder
47
- .map(key => labelSet.labels.find(l => l.name === key))
48
- .filter((l) => l != null)
49
- : labelSet.labels;
50
- if (labels.length === 0)
51
- return '{}';
52
- return '{' + labels.map(l => `${l.name}: ${l.value}`).join(', ') + '}';
84
+ export var labelSetToString = function labelSetToString(labelSet, keyOrder) {
85
+ if (labelSet === undefined) return '{}';
86
+ var labels = keyOrder != null ? keyOrder.map(function (key) {
87
+ return labelSet.labels.find(function (l) {
88
+ return l.name === key;
89
+ });
90
+ }).filter(function (l) {
91
+ return l != null;
92
+ }) : labelSet.labels;
93
+ if (labels.length === 0) return '{}';
94
+ return '{' + labels.map(function (l) {
95
+ return "".concat(l.name, ": ").concat(l.value);
96
+ }).join(', ') + '}';
53
97
  };
98
+
54
99
  // Build a comparator for LabelSets: text keys first (for grouping), then numeric keys.
55
100
  // Also returns the key order so labelSetToString can use the same ordering.
56
- export const createLabelSetComparator = (labelSets) => {
57
- const numericKeys = getNumericKeys(labelSets);
58
- const keyOrder = getSortedKeys(labelSets, numericKeys);
59
- const compare = (a, b) => {
60
- const aMap = new Map(a.labels.map(l => [l.name, l.value]));
61
- const bMap = new Map(b.labels.map(l => [l.name, l.value]));
62
- for (const key of keyOrder) {
63
- const aVal = aMap.get(key) ?? '';
64
- const bVal = bMap.get(key) ?? '';
65
- if (numericKeys.has(key)) {
66
- const diff = Number(aVal) - Number(bVal);
67
- if (diff !== 0)
68
- return diff;
69
- }
70
- else {
71
- const cmp = aVal.localeCompare(bVal);
72
- if (cmp !== 0)
73
- return cmp;
74
- }
101
+ export var createLabelSetComparator = function createLabelSetComparator(labelSets) {
102
+ var numericKeys = getNumericKeys(labelSets);
103
+ var keyOrder = getSortedKeys(labelSets, numericKeys);
104
+ var compare = function compare(a, b) {
105
+ var aMap = new Map(a.labels.map(function (l) {
106
+ return [l.name, l.value];
107
+ }));
108
+ var bMap = new Map(b.labels.map(function (l) {
109
+ return [l.name, l.value];
110
+ }));
111
+ var _iterator4 = _createForOfIteratorHelper(keyOrder),
112
+ _step4;
113
+ try {
114
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
115
+ var _aMap$get, _bMap$get;
116
+ var key = _step4.value;
117
+ var aVal = (_aMap$get = aMap.get(key)) !== null && _aMap$get !== void 0 ? _aMap$get : '';
118
+ var bVal = (_bMap$get = bMap.get(key)) !== null && _bMap$get !== void 0 ? _bMap$get : '';
119
+ if (numericKeys.has(key)) {
120
+ var diff = Number(aVal) - Number(bVal);
121
+ if (diff !== 0) return diff;
122
+ } else {
123
+ var cmp = aVal.localeCompare(bVal);
124
+ if (cmp !== 0) return cmp;
75
125
  }
76
- return 0;
77
- };
78
- return { compare, keyOrder };
79
- };
126
+ }
127
+ } catch (err) {
128
+ _iterator4.e(err);
129
+ } finally {
130
+ _iterator4.f();
131
+ }
132
+ return 0;
133
+ };
134
+ return {
135
+ compare: compare,
136
+ keyOrder: keyOrder
137
+ };
138
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileFlameChart/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAoC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAwB,WAAW,EAAQ,MAAM,eAAe,CAAC;AAKxE,OAAO,EAAsB,aAAa,EAAa,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,oCAAoC,CAAC;AAuCpE,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;CACvC;AA+BD,eAAO,MAAM,iBAAiB,GAAI,kKAY/B,sBAAsB,KAAG,GAAG,CAAC,OAuM/B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileFlameChart/index.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAoC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAQpF,OAAO,EAAwB,WAAW,EAAQ,MAAM,eAAe,CAAC;AAKxE,OAAO,EAAsB,aAAa,EAAa,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,oCAAoC,CAAC;AA4CpE,UAAU,sBAAsB;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,wBAAwB,CAAC,EAAE,MAAM,IAAI,CAAC;CACvC;AA+BD,eAAO,MAAM,iBAAiB,GAAI,kKAY/B,sBAAsB,KAAG,GAAG,CAAC,OAqM/B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,4 +1,20 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
10
+ function _toArray(r) { return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest(); }
11
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
12
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
13
+ 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."); }
14
+ 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; } }
15
+ 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; }
16
+ 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; } }
17
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
2
18
  // Copyright 2022 The Parca Authors
3
19
  // Licensed under the Apache License, Version 2.0 (the "License");
4
20
  // you may not use this file except in compliance with the License.
@@ -11,149 +27,271 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
27
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
28
  // See the License for the specific language governing permissions and
13
29
  // limitations under the License.
30
+
14
31
  import { useEffect, useMemo, useRef } from 'react';
15
- import { createParser, useQueryState } from 'nuqs';
16
32
  import { QueryRequest_ReportType } from '@parca/client';
17
- import { Button, useParcaContext } from '@parca/components';
33
+ import { Button, useParcaContext, useURLState, useURLStateCustom } from '@parca/components';
18
34
  import { Matcher, MatcherTypes, Query } from '@parca/parser';
19
35
  import { TimeUnits, formatDate, formatDuration } from '@parca/utilities';
20
36
  import ProfileFlameGraph, { validateFlameChartQuery } from '../ProfileFlameGraph';
21
37
  import { boundsFromProfileSource } from '../ProfileFlameGraph/FlameGraphArrow/utils';
22
38
  import { MergedProfileSource, timeFormat } from '../ProfileSource';
23
39
  import { useProfileFilters } from '../ProfileView/components/ProfileFilters/useProfileFilters';
24
- import { flamechartDimensionParser } from '../hooks/urlParsers';
25
40
  import { useQuery } from '../useQuery';
26
41
  import { SamplesStrip } from './SamplesStrips';
27
- const timeframeParser = createParser({
28
- parse: (value) => {
29
- try {
30
- const [labelPart, boundsPart] = value.split('|');
31
- if (labelPart != null && boundsPart != null) {
32
- const labels = labelPart.split(',').map(labelStr => {
33
- const [name, ...rest] = labelStr.split(':');
34
- return { name, value: rest.join(':') };
35
- });
36
- const [startMs, endMs] = boundsPart.split(',').map(Number);
37
- if (labels.length > 0 && !isNaN(startMs) && !isNaN(endMs)) {
38
- return {
39
- labels: { labels },
40
- bounds: [startMs, endMs],
41
- };
42
- }
43
- }
44
- }
45
- catch {
46
- // Ignore parsing errors
42
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
43
+ var TimeframeStateSerializer = {
44
+ parse: function parse(value) {
45
+ if (value == null || value === '' || value === 'undefined' || Array.isArray(value)) {
46
+ return undefined;
47
+ }
48
+ try {
49
+ var _value$split = value.split('|'),
50
+ _value$split2 = _slicedToArray(_value$split, 2),
51
+ labelPart = _value$split2[0],
52
+ boundsPart = _value$split2[1];
53
+ if (labelPart != null && boundsPart != null) {
54
+ var labels = labelPart.split(',').map(function (labelStr) {
55
+ var _labelStr$split = labelStr.split(':'),
56
+ _labelStr$split2 = _toArray(_labelStr$split),
57
+ name = _labelStr$split2[0],
58
+ rest = _arrayLikeToArray(_labelStr$split2).slice(1);
59
+ return {
60
+ name: name,
61
+ value: rest.join(':')
62
+ };
63
+ });
64
+ var _boundsPart$split$map = boundsPart.split(',').map(Number),
65
+ _boundsPart$split$map2 = _slicedToArray(_boundsPart$split$map, 2),
66
+ startMs = _boundsPart$split$map2[0],
67
+ endMs = _boundsPart$split$map2[1];
68
+ if (labels.length > 0 && !isNaN(startMs) && !isNaN(endMs)) {
69
+ return {
70
+ labels: {
71
+ labels: labels
72
+ },
73
+ bounds: [startMs, endMs]
74
+ };
47
75
  }
48
- return null;
49
- },
50
- serialize: (value) => {
51
- const labelsStr = value.labels.labels.map(l => `${l.name}:${l.value}`).join(',');
52
- return `${labelsStr}|${value.bounds[0]},${value.bounds[1]}`;
53
- },
54
- }).withOptions({ history: 'replace' });
76
+ }
77
+ } catch (_unused) {
78
+ // Ignore parsing errors
79
+ }
80
+ return undefined;
81
+ },
82
+ stringify: function stringify(value) {
83
+ if (value == null) {
84
+ return '';
85
+ }
86
+ var labelsStr = value.labels.labels.map(function (l) {
87
+ return "".concat(l.name, ":").concat(l.value);
88
+ }).join(',');
89
+ return "".concat(labelsStr, "|").concat(value.bounds[0], ",").concat(value.bounds[1]);
90
+ }
91
+ };
55
92
  // Helper to create a filtered profile source with narrowed time bounds
56
93
  // and dimension label matchers from the selected strip.
57
- const createFilteredProfileSource = (profileSource, selectedTimeframe) => {
58
- if (!(profileSource instanceof MergedProfileSource)) {
59
- return null;
60
- }
61
- // The bounds are in milliseconds, convert to nanoseconds for the profile source
62
- // Round to integers since BigInt requires integer values
63
- const mergeFrom = BigInt(Math.round(selectedTimeframe.bounds[0])) * 1000000n;
64
- const mergeTo = BigInt(Math.round(selectedTimeframe.bounds[1])) * 1000000n;
65
- // Add dimension labels as additional matchers to the query
66
- const dimensionMatchers = selectedTimeframe.labels.labels.map(l => new Matcher(l.name, MatcherTypes.MatchEqual, l.value));
67
- const query = new Query(profileSource.query.profType, [...profileSource.query.matchers, ...dimensionMatchers], '');
68
- return new MergedProfileSource(mergeFrom, mergeTo, query);
94
+ var createFilteredProfileSource = function createFilteredProfileSource(profileSource, selectedTimeframe) {
95
+ if (!(profileSource instanceof MergedProfileSource)) {
96
+ return null;
97
+ }
98
+
99
+ // The bounds are in milliseconds, convert to nanoseconds for the profile source
100
+ // Round to integers since BigInt requires integer values
101
+ var mergeFrom = BigInt(Math.round(selectedTimeframe.bounds[0])) * 1000000n;
102
+ var mergeTo = BigInt(Math.round(selectedTimeframe.bounds[1])) * 1000000n;
103
+
104
+ // Add dimension labels as additional matchers to the query
105
+ var dimensionMatchers = selectedTimeframe.labels.labels.map(function (l) {
106
+ return new Matcher(l.name, MatcherTypes.MatchEqual, l.value);
107
+ });
108
+ var query = new Query(profileSource.query.profType, [].concat(_toConsumableArray(profileSource.query.matchers), _toConsumableArray(dimensionMatchers)), '');
109
+ return new MergedProfileSource(mergeFrom, mergeTo, query);
69
110
  };
70
- export const ProfileFlameChart = ({ samplesData, queryClient, profileSource, width, total, filtered, profileType, isHalfScreen, metadataMappingFiles, metadataLoading, onSwitchToFifteenMinutes, }) => {
71
- const { enableFlamechartFiltering } = useParcaContext();
72
- const { protoFilters } = useProfileFilters();
73
- const zoomControlsRef = useRef(null);
74
- const [selectedTimeframe, setSelectedTimeframe] = useQueryState('flamechart_timeframe', timeframeParser);
75
- // Read flamechart dimension from URL state to detect changes
76
- const [flamechartDimension] = useQueryState('flamechart_dimension', flamechartDimensionParser.withDefault([]));
77
- // Reset selection when the parent time range (profileSource) changes
78
- const timeBoundsKey = boundsFromProfileSource(profileSource).join(',');
79
- const prevTimeBoundsKey = useRef(timeBoundsKey);
80
- useEffect(() => {
81
- if (prevTimeBoundsKey.current !== timeBoundsKey) {
82
- prevTimeBoundsKey.current = timeBoundsKey;
83
- void setSelectedTimeframe(null);
84
- }
85
- }, [timeBoundsKey, setSelectedTimeframe]);
86
- // Reset selection when the dimension changes
87
- const dimensionKey = (flamechartDimension ?? []).join(',');
88
- const prevDimensionKey = useRef(dimensionKey);
89
- useEffect(() => {
90
- if (prevDimensionKey.current !== dimensionKey) {
91
- prevDimensionKey.current = dimensionKey;
92
- void setSelectedTimeframe(null);
93
- }
94
- }, [dimensionKey, setSelectedTimeframe]);
95
- // Handle timeframe selection from strips
96
- const handleSelectedTimeframe = (labels, bounds) => {
97
- if (bounds === undefined) {
98
- void setSelectedTimeframe(null);
99
- }
100
- else {
101
- void setSelectedTimeframe({ labels, bounds });
102
- }
111
+ export var ProfileFlameChart = function ProfileFlameChart(_ref) {
112
+ var samplesData = _ref.samplesData,
113
+ queryClient = _ref.queryClient,
114
+ profileSource = _ref.profileSource,
115
+ width = _ref.width,
116
+ total = _ref.total,
117
+ filtered = _ref.filtered,
118
+ profileType = _ref.profileType,
119
+ isHalfScreen = _ref.isHalfScreen,
120
+ metadataMappingFiles = _ref.metadataMappingFiles,
121
+ metadataLoading = _ref.metadataLoading,
122
+ onSwitchToFifteenMinutes = _ref.onSwitchToFifteenMinutes;
123
+ var _useParcaContext = useParcaContext(),
124
+ enableFlamechartFiltering = _useParcaContext.enableFlamechartFiltering;
125
+ var _useProfileFilters = useProfileFilters(),
126
+ protoFilters = _useProfileFilters.protoFilters;
127
+ var zoomControlsRef = useRef(null);
128
+ var _useURLStateCustom = useURLStateCustom('flamechart_timeframe', TimeframeStateSerializer),
129
+ _useURLStateCustom2 = _slicedToArray(_useURLStateCustom, 2),
130
+ selectedTimeframe = _useURLStateCustom2[0],
131
+ setSelectedTimeframe = _useURLStateCustom2[1];
132
+
133
+ // Read flamechart dimension from URL state to detect changes
134
+ var _useURLState = useURLState('flamechart_dimension', {
135
+ alwaysReturnArray: true
136
+ }),
137
+ _useURLState2 = _slicedToArray(_useURLState, 1),
138
+ flamechartDimension = _useURLState2[0];
139
+
140
+ // Reset selection when the parent time range (profileSource) changes
141
+ var timeBoundsKey = boundsFromProfileSource(profileSource).join(',');
142
+ var prevTimeBoundsKey = useRef(timeBoundsKey);
143
+ useEffect(function () {
144
+ if (prevTimeBoundsKey.current !== timeBoundsKey) {
145
+ prevTimeBoundsKey.current = timeBoundsKey;
146
+ setSelectedTimeframe(undefined);
147
+ }
148
+ }, [timeBoundsKey, setSelectedTimeframe]);
149
+
150
+ // Reset selection when the dimension changes
151
+ var dimensionKey = (flamechartDimension !== null && flamechartDimension !== void 0 ? flamechartDimension : []).join(',');
152
+ var prevDimensionKey = useRef(dimensionKey);
153
+ useEffect(function () {
154
+ if (prevDimensionKey.current !== dimensionKey) {
155
+ prevDimensionKey.current = dimensionKey;
156
+ setSelectedTimeframe(undefined);
157
+ }
158
+ }, [dimensionKey, setSelectedTimeframe]);
159
+
160
+ // Handle timeframe selection from strips
161
+ var handleSelectedTimeframe = function handleSelectedTimeframe(labels, bounds) {
162
+ if (bounds === undefined) {
163
+ setSelectedTimeframe(undefined);
164
+ } else {
165
+ setSelectedTimeframe({
166
+ labels: labels,
167
+ bounds: bounds
168
+ });
169
+ }
170
+ };
171
+
172
+ // Create filtered profile source when selection exists
173
+ var filteredProfileSource = useMemo(function () {
174
+ if (selectedTimeframe == null) return null;
175
+ return createFilteredProfileSource(profileSource, selectedTimeframe);
176
+ }, [profileSource, selectedTimeframe]);
177
+
178
+ // Query flamechart data only when a strip selection exists
179
+ var _useQuery = useQuery(queryClient, filteredProfileSource !== null && filteredProfileSource !== void 0 ? filteredProfileSource : profileSource, QueryRequest_ReportType.FLAMECHART, _objectSpread({
180
+ skip: selectedTimeframe == null || filteredProfileSource == null
181
+ }, enableFlamechartFiltering === true ? {
182
+ protoFilters: protoFilters
183
+ } : {})),
184
+ flamechartLoading = _useQuery.isLoading,
185
+ flamechartResponse = _useQuery.response,
186
+ flamechartError = _useQuery.error;
187
+ var flamechartArrow = (flamechartResponse === null || flamechartResponse === void 0 ? void 0 : flamechartResponse.report.oneofKind) === 'flamegraphArrow' ? flamechartResponse.report.flamegraphArrow : undefined;
188
+ var flamechartTotal = flamechartResponse != null ? BigInt(flamechartResponse.total) : total;
189
+ var flamechartFiltered = flamechartResponse != null ? BigInt(flamechartResponse.filtered) : filtered;
190
+
191
+ // Get time bounds from profile source for the strips
192
+ var timeBounds = boundsFromProfileSource(profileSource);
193
+
194
+ // Transform samples data for SamplesStrip component
195
+ var stripsData = useMemo(function () {
196
+ var _samplesData$stepMs;
197
+ if ((samplesData === null || samplesData === void 0 ? void 0 : samplesData.series) == null) return {
198
+ cpus: [],
199
+ data: [],
200
+ stepMs: 0
103
201
  };
104
- // Create filtered profile source when selection exists
105
- const filteredProfileSource = useMemo(() => {
106
- if (selectedTimeframe == null)
107
- return null;
108
- return createFilteredProfileSource(profileSource, selectedTimeframe);
109
- }, [profileSource, selectedTimeframe]);
110
- // Query flamechart data only when a strip selection exists
111
- const { isLoading: flamechartLoading, response: flamechartResponse, error: flamechartError, } = useQuery(queryClient, filteredProfileSource ?? profileSource, QueryRequest_ReportType.FLAMECHART, {
112
- skip: selectedTimeframe == null || filteredProfileSource == null,
113
- ...(enableFlamechartFiltering === true ? { protoFilters } : {}),
202
+ var cpus = samplesData.series.map(function (s) {
203
+ return s.labelset;
114
204
  });
115
- const flamechartArrow = flamechartResponse?.report.oneofKind === 'flamegraphArrow'
116
- ? flamechartResponse.report.flamegraphArrow
117
- : undefined;
118
- const flamechartTotal = flamechartResponse != null ? BigInt(flamechartResponse.total) : total;
119
- const flamechartFiltered = flamechartResponse != null ? BigInt(flamechartResponse.filtered) : filtered;
120
- // Get time bounds from profile source for the strips
121
- const timeBounds = boundsFromProfileSource(profileSource);
122
- // Transform samples data for SamplesStrip component
123
- const stripsData = useMemo(() => {
124
- if (samplesData?.series == null)
125
- return { cpus: [], data: [], stepMs: 0 };
126
- const cpus = samplesData.series.map(s => s.labelset);
127
- const data = samplesData.series.map(s => s.data);
128
- const stepMs = samplesData.stepMs ?? 0;
129
- return { cpus, data, stepMs };
130
- }, [samplesData?.series, samplesData?.stepMs]);
131
- const { isValid, isNonDelta, isDurationTooLong } = validateFlameChartQuery(profileSource);
132
- if (!isValid) {
133
- if (isDurationTooLong) {
134
- return (_jsxs("div", { className: "flex flex-col justify-center items-center p-10 text-center gap-4 text-sm", children: [_jsx("span", { children: "Flame chart is unavailable for queries longer than 15 minutes. Try reducing the time range to 15 minutes or selecting a point in the metrics graph." }), onSwitchToFifteenMinutes != null && (_jsx(Button, { variant: "primary", onClick: onSwitchToFifteenMinutes, children: "Switch to last 15 minutes" }))] }));
135
- }
136
- const message = isNonDelta
137
- ? 'To use the Flame chart, please switch to a Delta profile.'
138
- : 'Flame chart is unavailable for this query.';
139
- return (_jsx("div", { className: "flex flex-col justify-center p-10 text-center gap-6 text-sm", children: message }));
140
- }
141
- const hasDimension = (flamechartDimension ?? []).length > 0;
142
- const isStripsLoading = metadataLoading === true || !hasDimension || samplesData?.loading === true;
143
- if (!hasDimension && metadataLoading !== true) {
144
- return (_jsx("div", { className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm", children: "Select a label in the \"Samples group by\" dropdown above to view the samples strips." }));
205
+ var data = samplesData.series.map(function (s_0) {
206
+ return s_0.data;
207
+ });
208
+ var stepMs = (_samplesData$stepMs = samplesData.stepMs) !== null && _samplesData$stepMs !== void 0 ? _samplesData$stepMs : 0;
209
+ return {
210
+ cpus: cpus,
211
+ data: data,
212
+ stepMs: stepMs
213
+ };
214
+ }, [samplesData === null || samplesData === void 0 ? void 0 : samplesData.series, samplesData === null || samplesData === void 0 ? void 0 : samplesData.stepMs]);
215
+ var _validateFlameChartQu = validateFlameChartQuery(profileSource),
216
+ isValid = _validateFlameChartQu.isValid,
217
+ isNonDelta = _validateFlameChartQu.isNonDelta,
218
+ isDurationTooLong = _validateFlameChartQu.isDurationTooLong;
219
+ if (!isValid) {
220
+ if (isDurationTooLong) {
221
+ return /*#__PURE__*/_jsxs("div", {
222
+ className: "flex flex-col justify-center items-center p-10 text-center gap-4 text-sm",
223
+ children: [/*#__PURE__*/_jsx("span", {
224
+ children: "Flame chart is unavailable for queries longer than 15 minutes. Try reducing the time range to 15 minutes or selecting a point in the metrics graph."
225
+ }), onSwitchToFifteenMinutes != null && /*#__PURE__*/_jsx(Button, {
226
+ variant: "primary",
227
+ onClick: onSwitchToFifteenMinutes,
228
+ children: "Switch to last 15 minutes"
229
+ })]
230
+ });
145
231
  }
146
- return (_jsxs("div", { children: [(isStripsLoading || (stripsData.cpus.length > 0 && stripsData.data.length > 0)) && (_jsx("div", { className: "mb-2", children: _jsx(SamplesStrip, { loading: isStripsLoading, cpus: stripsData.cpus, data: stripsData.data, selectedTimeframe: selectedTimeframe, onSelectedTimeframe: handleSelectedTimeframe, width: width, bounds: [Number(timeBounds[0] / 1000000n), Number(timeBounds[1] / 1000000n)], stepMs: stripsData.stepMs }) })), selectedTimeframe != null &&
147
- (() => {
148
- const labels = selectedTimeframe.labels.labels
149
- .map(l => `${l.name} = ${l.value}`)
150
- .join(', ');
151
- const durationMs = selectedTimeframe.bounds[1] - selectedTimeframe.bounds[0];
152
- const duration = durationMs < 5000
153
- ? `${(durationMs / 1000).toFixed(1)}s`
154
- : formatDuration({ [TimeUnits.Milliseconds]: durationMs });
155
- const fmt = durationMs < 5000 ? "yyyy-MM-dd HH:mm:ss.SSS '(UTC)'" : timeFormat();
156
- return (_jsxs("div", { className: "flex items-center justify-between px-2 py-1", children: [_jsxs("div", { className: "text-xs font-medium text-gray-500 dark:text-gray-400", children: ["Samples matching ", labels, " over ", duration, " from", ' ', formatDate(new Date(selectedTimeframe.bounds[0]), fmt), " to", ' ', formatDate(new Date(selectedTimeframe.bounds[1]), fmt)] }), _jsx("div", { ref: zoomControlsRef })] }));
157
- })(), selectedTimeframe != null && filteredProfileSource != null ? (_jsx(ProfileFlameGraph, { arrow: flamechartArrow, loading: flamechartLoading, error: flamechartError, profileSource: filteredProfileSource, width: width, total: flamechartTotal, filtered: flamechartFiltered, profileType: profileType, isHalfScreen: isHalfScreen, metadataMappingFiles: metadataMappingFiles, metadataLoading: metadataLoading, isFlameChart: true, curPathArrow: [], setNewCurPathArrow: () => { }, zoomControlsRef: zoomControlsRef })) : (_jsx("div", { className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm", children: "Select a time range in the samples strips above to view the flamechart." }))] }));
232
+ var message = isNonDelta ? 'To use the Flame chart, please switch to a Delta profile.' : 'Flame chart is unavailable for this query.';
233
+ return /*#__PURE__*/_jsx("div", {
234
+ className: "flex flex-col justify-center p-10 text-center gap-6 text-sm",
235
+ children: message
236
+ });
237
+ }
238
+ var hasDimension = (flamechartDimension !== null && flamechartDimension !== void 0 ? flamechartDimension : []).length > 0;
239
+ var isStripsLoading = metadataLoading === true || !hasDimension || (samplesData === null || samplesData === void 0 ? void 0 : samplesData.loading) === true;
240
+ if (!hasDimension && metadataLoading !== true) {
241
+ return /*#__PURE__*/_jsx("div", {
242
+ className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm",
243
+ children: "Select a label in the \"Samples group by\" dropdown above to view the samples strips."
244
+ });
245
+ }
246
+ return /*#__PURE__*/_jsxs("div", {
247
+ children: [(isStripsLoading || stripsData.cpus.length > 0 && stripsData.data.length > 0) && /*#__PURE__*/_jsx("div", {
248
+ className: "mb-2",
249
+ children: /*#__PURE__*/_jsx(SamplesStrip, {
250
+ loading: isStripsLoading,
251
+ cpus: stripsData.cpus,
252
+ data: stripsData.data,
253
+ selectedTimeframe: selectedTimeframe,
254
+ onSelectedTimeframe: handleSelectedTimeframe,
255
+ width: width,
256
+ bounds: [Number(timeBounds[0] / 1000000n), Number(timeBounds[1] / 1000000n)],
257
+ stepMs: stripsData.stepMs
258
+ })
259
+ }), selectedTimeframe != null && function () {
260
+ var labels_0 = selectedTimeframe.labels.labels.map(function (l) {
261
+ return "".concat(l.name, " = ").concat(l.value);
262
+ }).join(', ');
263
+ var durationMs = selectedTimeframe.bounds[1] - selectedTimeframe.bounds[0];
264
+ var duration = durationMs < 5000 ? "".concat((durationMs / 1000).toFixed(1), "s") : formatDuration(_defineProperty({}, TimeUnits.Milliseconds, durationMs));
265
+ var fmt = durationMs < 5000 ? "yyyy-MM-dd HH:mm:ss.SSS '(UTC)'" : timeFormat();
266
+ return /*#__PURE__*/_jsxs("div", {
267
+ className: "flex items-center justify-between px-2 py-1",
268
+ children: [/*#__PURE__*/_jsxs("div", {
269
+ className: "text-xs font-medium text-gray-500 dark:text-gray-400",
270
+ children: ["Samples matching ", labels_0, " over ", duration, " from", ' ', formatDate(new Date(selectedTimeframe.bounds[0]), fmt), " to", ' ', formatDate(new Date(selectedTimeframe.bounds[1]), fmt)]
271
+ }), /*#__PURE__*/_jsx("div", {
272
+ ref: zoomControlsRef
273
+ })]
274
+ });
275
+ }(), selectedTimeframe != null && filteredProfileSource != null ? /*#__PURE__*/_jsx(ProfileFlameGraph, {
276
+ arrow: flamechartArrow,
277
+ loading: flamechartLoading,
278
+ error: flamechartError,
279
+ profileSource: filteredProfileSource,
280
+ width: width,
281
+ total: flamechartTotal,
282
+ filtered: flamechartFiltered,
283
+ profileType: profileType,
284
+ isHalfScreen: isHalfScreen,
285
+ metadataMappingFiles: metadataMappingFiles,
286
+ metadataLoading: metadataLoading,
287
+ isFlameChart: true,
288
+ curPathArrow: [],
289
+ setNewCurPathArrow: function setNewCurPathArrow() {},
290
+ zoomControlsRef: zoomControlsRef
291
+ }) : /*#__PURE__*/_jsx("div", {
292
+ className: "flex justify-center items-center py-10 text-gray-500 dark:text-gray-400 text-sm",
293
+ children: "Select a time range in the samples strips above to view the flamechart."
294
+ })]
295
+ });
158
296
  };
159
- export default ProfileFlameChart;
297
+ export default ProfileFlameChart;