@perses-dev/tracing-gantt-chart-plugin 0.6.0

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 (189) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/__mf/css/async/341.6c6463ea.css +1 -0
  4. package/__mf/css/async/759.6c6463ea.css +1 -0
  5. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  6. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  7. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  8. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  9. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  10. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  11. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  12. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  13. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  17. package/__mf/js/788.91bbf7bd.js +5 -0
  18. package/__mf/js/TracingGanttChart.1a922a19.js +5 -0
  19. package/__mf/js/async/156.5a401ecb.js +1 -0
  20. package/__mf/js/async/173.6314a363.js +2 -0
  21. package/__mf/js/async/173.6314a363.js.LICENSE.txt +19 -0
  22. package/__mf/js/async/620.1d1ce390.js +2 -0
  23. package/__mf/js/async/620.1d1ce390.js.LICENSE.txt +9 -0
  24. package/__mf/js/async/651.3ea371e5.js +1 -0
  25. package/__mf/js/async/694.4580ad20.js +1 -0
  26. package/__mf/js/async/740.babbb403.js +1 -0
  27. package/__mf/js/async/75.d81e6bbf.js +1 -0
  28. package/__mf/js/async/770.5431adef.js +1 -0
  29. package/__mf/js/async/783.3c2c57f6.js +110 -0
  30. package/__mf/js/async/783.3c2c57f6.js.LICENSE.txt +27 -0
  31. package/__mf/js/async/844.556cc34d.js +66 -0
  32. package/__mf/js/async/844.556cc34d.js.LICENSE.txt +84 -0
  33. package/__mf/js/async/928.096f73eb.js +1 -0
  34. package/__mf/js/async/960.478a8f11.js +2 -0
  35. package/__mf/js/async/960.478a8f11.js.LICENSE.txt +8 -0
  36. package/__mf/js/async/964.a98cab40.js +2 -0
  37. package/__mf/js/async/964.a98cab40.js.LICENSE.txt +9 -0
  38. package/__mf/js/async/981.bc5132f8.js +2 -0
  39. package/__mf/js/async/981.bc5132f8.js.LICENSE.txt +8 -0
  40. package/__mf/js/async/__federation_expose_TracingGanttChart.5ab86c44.js +1 -0
  41. package/__mf/js/async/lib-router.36c0d526.js +2 -0
  42. package/__mf/js/async/lib-router.36c0d526.js.LICENSE.txt +32 -0
  43. package/__mf/js/main.e75dea7b.js +1 -0
  44. package/lib/TracingGanttChart/DetailPane/Attributes.d.ts +9 -0
  45. package/lib/TracingGanttChart/DetailPane/Attributes.d.ts.map +1 -0
  46. package/lib/TracingGanttChart/DetailPane/Attributes.js +66 -0
  47. package/lib/TracingGanttChart/DetailPane/Attributes.js.map +1 -0
  48. package/lib/TracingGanttChart/DetailPane/DetailPane.d.ts +14 -0
  49. package/lib/TracingGanttChart/DetailPane/DetailPane.d.ts.map +1 -0
  50. package/lib/TracingGanttChart/DetailPane/DetailPane.js +95 -0
  51. package/lib/TracingGanttChart/DetailPane/DetailPane.js.map +1 -0
  52. package/lib/TracingGanttChart/DetailPane/SpanEvents.d.ts +8 -0
  53. package/lib/TracingGanttChart/DetailPane/SpanEvents.d.ts.map +1 -0
  54. package/lib/TracingGanttChart/DetailPane/SpanEvents.js +54 -0
  55. package/lib/TracingGanttChart/DetailPane/SpanEvents.js.map +1 -0
  56. package/lib/TracingGanttChart/GanttTable/GanttTable.d.ts +13 -0
  57. package/lib/TracingGanttChart/GanttTable/GanttTable.d.ts.map +1 -0
  58. package/lib/TracingGanttChart/GanttTable/GanttTable.js +93 -0
  59. package/lib/TracingGanttChart/GanttTable/GanttTable.js.map +1 -0
  60. package/lib/TracingGanttChart/GanttTable/GanttTableHeader.d.ts +12 -0
  61. package/lib/TracingGanttChart/GanttTable/GanttTableHeader.d.ts.map +1 -0
  62. package/lib/TracingGanttChart/GanttTable/GanttTableHeader.js +56 -0
  63. package/lib/TracingGanttChart/GanttTable/GanttTableHeader.js.map +1 -0
  64. package/lib/TracingGanttChart/GanttTable/GanttTableProvider.d.ts +23 -0
  65. package/lib/TracingGanttChart/GanttTable/GanttTableProvider.d.ts.map +1 -0
  66. package/lib/TracingGanttChart/GanttTable/GanttTableProvider.js +45 -0
  67. package/lib/TracingGanttChart/GanttTable/GanttTableProvider.js.map +1 -0
  68. package/lib/TracingGanttChart/GanttTable/GanttTableRow.d.ts +15 -0
  69. package/lib/TracingGanttChart/GanttTable/GanttTableRow.d.ts.map +1 -0
  70. package/lib/TracingGanttChart/GanttTable/GanttTableRow.js +56 -0
  71. package/lib/TracingGanttChart/GanttTable/GanttTableRow.js.map +1 -0
  72. package/lib/TracingGanttChart/GanttTable/ResizableDivider.d.ts +9 -0
  73. package/lib/TracingGanttChart/GanttTable/ResizableDivider.d.ts.map +1 -0
  74. package/lib/TracingGanttChart/GanttTable/ResizableDivider.js +86 -0
  75. package/lib/TracingGanttChart/GanttTable/ResizableDivider.js.map +1 -0
  76. package/lib/TracingGanttChart/GanttTable/SpanDuration.d.ts +14 -0
  77. package/lib/TracingGanttChart/GanttTable/SpanDuration.d.ts.map +1 -0
  78. package/lib/TracingGanttChart/GanttTable/SpanDuration.js +75 -0
  79. package/lib/TracingGanttChart/GanttTable/SpanDuration.js.map +1 -0
  80. package/lib/TracingGanttChart/GanttTable/SpanIndents.d.ts +14 -0
  81. package/lib/TracingGanttChart/GanttTable/SpanIndents.d.ts.map +1 -0
  82. package/lib/TracingGanttChart/GanttTable/SpanIndents.js +90 -0
  83. package/lib/TracingGanttChart/GanttTable/SpanIndents.js.map +1 -0
  84. package/lib/TracingGanttChart/GanttTable/SpanName.d.ts +11 -0
  85. package/lib/TracingGanttChart/GanttTable/SpanName.d.ts.map +1 -0
  86. package/lib/TracingGanttChart/GanttTable/SpanName.js +61 -0
  87. package/lib/TracingGanttChart/GanttTable/SpanName.js.map +1 -0
  88. package/lib/TracingGanttChart/MiniGanttChart/Canvas.d.ts +13 -0
  89. package/lib/TracingGanttChart/MiniGanttChart/Canvas.d.ts.map +1 -0
  90. package/lib/TracingGanttChart/MiniGanttChart/Canvas.js +243 -0
  91. package/lib/TracingGanttChart/MiniGanttChart/Canvas.js.map +1 -0
  92. package/lib/TracingGanttChart/MiniGanttChart/MiniGanttChart.d.ts +13 -0
  93. package/lib/TracingGanttChart/MiniGanttChart/MiniGanttChart.d.ts.map +1 -0
  94. package/lib/TracingGanttChart/MiniGanttChart/MiniGanttChart.js +51 -0
  95. package/lib/TracingGanttChart/MiniGanttChart/MiniGanttChart.js.map +1 -0
  96. package/lib/TracingGanttChart/MiniGanttChart/draw.d.ts +3 -0
  97. package/lib/TracingGanttChart/MiniGanttChart/draw.d.ts.map +1 -0
  98. package/lib/TracingGanttChart/MiniGanttChart/draw.js +48 -0
  99. package/lib/TracingGanttChart/MiniGanttChart/draw.js.map +1 -0
  100. package/lib/TracingGanttChart/Ticks.d.ts +16 -0
  101. package/lib/TracingGanttChart/Ticks.d.ts.map +1 -0
  102. package/lib/TracingGanttChart/Ticks.js +94 -0
  103. package/lib/TracingGanttChart/Ticks.js.map +1 -0
  104. package/lib/TracingGanttChart/TracingGanttChart.d.ts +17 -0
  105. package/lib/TracingGanttChart/TracingGanttChart.d.ts.map +1 -0
  106. package/lib/TracingGanttChart/TracingGanttChart.js +106 -0
  107. package/lib/TracingGanttChart/TracingGanttChart.js.map +1 -0
  108. package/lib/TracingGanttChart/palette.d.ts +6 -0
  109. package/lib/TracingGanttChart/palette.d.ts.map +1 -0
  110. package/lib/TracingGanttChart/palette.js +64 -0
  111. package/lib/TracingGanttChart/palette.js.map +1 -0
  112. package/lib/TracingGanttChart/trace.d.ts +45 -0
  113. package/lib/TracingGanttChart/trace.d.ts.map +1 -0
  114. package/lib/TracingGanttChart/trace.js +109 -0
  115. package/lib/TracingGanttChart/trace.js.map +1 -0
  116. package/lib/TracingGanttChart/utils.d.ts +18 -0
  117. package/lib/TracingGanttChart/utils.d.ts.map +1 -0
  118. package/lib/TracingGanttChart/utils.js +48 -0
  119. package/lib/TracingGanttChart/utils.js.map +1 -0
  120. package/lib/TracingGanttChart.d.ts +5 -0
  121. package/lib/TracingGanttChart.d.ts.map +1 -0
  122. package/lib/TracingGanttChart.js +23 -0
  123. package/lib/TracingGanttChart.js.map +1 -0
  124. package/lib/TracingGanttChartPanel.d.ts +17 -0
  125. package/lib/TracingGanttChartPanel.d.ts.map +1 -0
  126. package/lib/TracingGanttChartPanel.js +45 -0
  127. package/lib/TracingGanttChartPanel.js.map +1 -0
  128. package/lib/bootstrap.d.ts +2 -0
  129. package/lib/bootstrap.d.ts.map +1 -0
  130. package/lib/bootstrap.js +19 -0
  131. package/lib/bootstrap.js.map +1 -0
  132. package/lib/cjs/TracingGanttChart/DetailPane/Attributes.js +74 -0
  133. package/lib/cjs/TracingGanttChart/DetailPane/DetailPane.js +106 -0
  134. package/lib/cjs/TracingGanttChart/DetailPane/SpanEvents.js +67 -0
  135. package/lib/cjs/TracingGanttChart/GanttTable/GanttTable.js +101 -0
  136. package/lib/cjs/TracingGanttChart/GanttTable/GanttTableHeader.js +64 -0
  137. package/lib/cjs/TracingGanttChart/GanttTable/GanttTableProvider.js +60 -0
  138. package/lib/cjs/TracingGanttChart/GanttTable/GanttTableRow.js +64 -0
  139. package/lib/cjs/TracingGanttChart/GanttTable/ResizableDivider.js +94 -0
  140. package/lib/cjs/TracingGanttChart/GanttTable/SpanDuration.js +81 -0
  141. package/lib/cjs/TracingGanttChart/GanttTable/SpanIndents.js +97 -0
  142. package/lib/cjs/TracingGanttChart/GanttTable/SpanName.js +72 -0
  143. package/lib/cjs/TracingGanttChart/MiniGanttChart/Canvas.js +256 -0
  144. package/lib/cjs/TracingGanttChart/MiniGanttChart/MiniGanttChart.js +59 -0
  145. package/lib/cjs/TracingGanttChart/MiniGanttChart/draw.js +56 -0
  146. package/lib/cjs/TracingGanttChart/Ticks.js +106 -0
  147. package/lib/cjs/TracingGanttChart/TracingGanttChart.js +109 -0
  148. package/lib/cjs/TracingGanttChart/palette.js +83 -0
  149. package/lib/cjs/TracingGanttChart/trace.js +113 -0
  150. package/lib/cjs/TracingGanttChart/utils.js +76 -0
  151. package/lib/cjs/TracingGanttChart.js +31 -0
  152. package/lib/cjs/TracingGanttChartPanel.js +53 -0
  153. package/lib/cjs/bootstrap.js +26 -0
  154. package/lib/cjs/env.d.js +14 -0
  155. package/lib/cjs/gantt-chart-model.js +28 -0
  156. package/lib/cjs/getPluginModule.js +27 -0
  157. package/lib/cjs/index-federation.js +55 -0
  158. package/lib/cjs/index.js +27 -0
  159. package/lib/cjs/setup-tests.js +19 -0
  160. package/lib/cjs/test/convert/jaeger.js +86 -0
  161. package/lib/env.d.js +15 -0
  162. package/lib/env.d.js.map +1 -0
  163. package/lib/gantt-chart-model.d.ts +17 -0
  164. package/lib/gantt-chart-model.d.ts.map +1 -0
  165. package/lib/gantt-chart-model.js +22 -0
  166. package/lib/gantt-chart-model.js.map +1 -0
  167. package/lib/getPluginModule.d.ts +6 -0
  168. package/lib/getPluginModule.d.ts.map +1 -0
  169. package/lib/getPluginModule.js +16 -0
  170. package/lib/getPluginModule.js.map +1 -0
  171. package/lib/index-federation.d.ts +1 -0
  172. package/lib/index-federation.d.ts.map +1 -0
  173. package/lib/index-federation.js +15 -0
  174. package/lib/index-federation.js.map +1 -0
  175. package/lib/index.d.ts +5 -0
  176. package/lib/index.d.ts.map +1 -0
  177. package/lib/index.js +6 -0
  178. package/lib/index.js.map +1 -0
  179. package/lib/setup-tests.d.ts +2 -0
  180. package/lib/setup-tests.d.ts.map +1 -0
  181. package/lib/setup-tests.js +17 -0
  182. package/lib/setup-tests.js.map +1 -0
  183. package/lib/test/convert/jaeger.d.ts +41 -0
  184. package/lib/test/convert/jaeger.d.ts.map +1 -0
  185. package/lib/test/convert/jaeger.js +78 -0
  186. package/lib/test/convert/jaeger.js.map +1 -0
  187. package/mf-manifest.json +233 -0
  188. package/mf-stats.json +269 -0
  189. package/package.json +58 -0
@@ -0,0 +1,106 @@
1
+ // Copyright 2024 The Perses 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
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { useMemo, useRef, useState } from 'react';
15
+ import { Box, Stack, useTheme } from '@mui/material';
16
+ import { MiniGanttChart } from './MiniGanttChart/MiniGanttChart';
17
+ import { DetailPane } from './DetailPane/DetailPane';
18
+ import { GanttTable } from './GanttTable/GanttTable';
19
+ import { GanttTableProvider } from './GanttTable/GanttTableProvider';
20
+ import { ResizableDivider } from './GanttTable/ResizableDivider';
21
+ import { getTraceModel } from './trace';
22
+ /**
23
+ * The core GanttChart panel for Perses.
24
+ *
25
+ * The UI/UX of this panel is based on Jaeger UI, licensed under Apache License, Version 2.0.
26
+ * https://github.com/jaegertracing/jaeger-ui
27
+ */ export function TracingGanttChart(props) {
28
+ const { options, attributeLinks, trace: otlpTrace } = props;
29
+ const theme = useTheme();
30
+ const trace = useMemo(()=>{
31
+ try {
32
+ return getTraceModel(otlpTrace);
33
+ } catch (e) {
34
+ throw new Error(`Error: unable to parse trace: ${e}`);
35
+ }
36
+ }, [
37
+ otlpTrace
38
+ ]);
39
+ const [viewport, setViewport] = useState({
40
+ startTimeUnixMs: trace.startTimeUnixMs,
41
+ endTimeUnixMs: trace.endTimeUnixMs
42
+ });
43
+ const [selectedSpan, setSelectedSpan] = useState(undefined);
44
+ const ganttChart = useRef(null);
45
+ // tableWidth only comes to effect if the detail pane is visible.
46
+ // setTableWidth() is only called by <ResizableDivider />
47
+ const [tableWidth, setTableWidth] = useState(0.82);
48
+ const gap = 2;
49
+ return /*#__PURE__*/ _jsxs(Stack, {
50
+ ref: ganttChart,
51
+ direction: "row",
52
+ sx: {
53
+ height: '100%',
54
+ minHeight: '240px',
55
+ gap
56
+ },
57
+ children: [
58
+ /*#__PURE__*/ _jsxs(Stack, {
59
+ sx: {
60
+ flexGrow: 1,
61
+ gap
62
+ },
63
+ children: [
64
+ /*#__PURE__*/ _jsx(MiniGanttChart, {
65
+ options: options,
66
+ trace: trace,
67
+ viewport: viewport,
68
+ setViewport: setViewport
69
+ }),
70
+ /*#__PURE__*/ _jsx(GanttTableProvider, {
71
+ children: /*#__PURE__*/ _jsx(GanttTable, {
72
+ options: options,
73
+ trace: trace,
74
+ viewport: viewport,
75
+ selectedSpan: selectedSpan,
76
+ onSpanClick: setSelectedSpan
77
+ })
78
+ })
79
+ ]
80
+ }),
81
+ selectedSpan && /*#__PURE__*/ _jsxs(_Fragment, {
82
+ children: [
83
+ /*#__PURE__*/ _jsx(ResizableDivider, {
84
+ parentRef: ganttChart,
85
+ spacing: parseInt(theme.spacing(gap)),
86
+ onMove: setTableWidth
87
+ }),
88
+ /*#__PURE__*/ _jsx(Box, {
89
+ sx: {
90
+ width: `${(1 - tableWidth) * 100}%`,
91
+ overflow: 'auto'
92
+ },
93
+ children: /*#__PURE__*/ _jsx(DetailPane, {
94
+ attributeLinks: attributeLinks,
95
+ trace: trace,
96
+ span: selectedSpan,
97
+ onCloseBtnClick: ()=>setSelectedSpan(undefined)
98
+ })
99
+ })
100
+ ]
101
+ })
102
+ ]
103
+ });
104
+ }
105
+
106
+ //# sourceMappingURL=TracingGanttChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/TracingGanttChart/TracingGanttChart.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement, useMemo, useRef, useState } from 'react';\nimport { Box, Stack, useTheme } from '@mui/material';\nimport { otlptracev1 } from '@perses-dev/core';\nimport { TracingGanttChartOptions } from '../gantt-chart-model';\nimport { MiniGanttChart } from './MiniGanttChart/MiniGanttChart';\nimport { DetailPane } from './DetailPane/DetailPane';\nimport { Viewport } from './utils';\nimport { GanttTable } from './GanttTable/GanttTable';\nimport { GanttTableProvider } from './GanttTable/GanttTableProvider';\nimport { ResizableDivider } from './GanttTable/ResizableDivider';\nimport { AttributeLinks } from './DetailPane/Attributes';\nimport { getTraceModel, Span } from './trace';\n\nexport interface TracingGanttChartProps {\n options: TracingGanttChartOptions;\n attributeLinks?: AttributeLinks;\n trace: otlptracev1.TracesData;\n}\n\n/**\n * The core GanttChart panel for Perses.\n *\n * The UI/UX of this panel is based on Jaeger UI, licensed under Apache License, Version 2.0.\n * https://github.com/jaegertracing/jaeger-ui\n */\nexport function TracingGanttChart(props: TracingGanttChartProps): ReactElement {\n const { options, attributeLinks, trace: otlpTrace } = props;\n\n const theme = useTheme();\n const trace = useMemo(() => {\n try {\n return getTraceModel(otlpTrace);\n } catch (e) {\n throw new Error(`Error: unable to parse trace: ${e}`);\n }\n }, [otlpTrace]);\n const [viewport, setViewport] = useState<Viewport>({\n startTimeUnixMs: trace.startTimeUnixMs,\n endTimeUnixMs: trace.endTimeUnixMs,\n });\n const [selectedSpan, setSelectedSpan] = useState<Span | undefined>(undefined);\n\n const ganttChart = useRef<HTMLDivElement>(null);\n // tableWidth only comes to effect if the detail pane is visible.\n // setTableWidth() is only called by <ResizableDivider />\n const [tableWidth, setTableWidth] = useState<number>(0.82);\n const gap = 2;\n\n return (\n <Stack ref={ganttChart} direction=\"row\" sx={{ height: '100%', minHeight: '240px', gap }}>\n <Stack sx={{ flexGrow: 1, gap }}>\n <MiniGanttChart options={options} trace={trace} viewport={viewport} setViewport={setViewport} />\n <GanttTableProvider>\n <GanttTable\n options={options}\n trace={trace}\n viewport={viewport}\n selectedSpan={selectedSpan}\n onSpanClick={setSelectedSpan}\n />\n </GanttTableProvider>\n </Stack>\n {selectedSpan && (\n <>\n <ResizableDivider parentRef={ganttChart} spacing={parseInt(theme.spacing(gap))} onMove={setTableWidth} />\n <Box sx={{ width: `${(1 - tableWidth) * 100}%`, overflow: 'auto' }}>\n <DetailPane\n attributeLinks={attributeLinks}\n trace={trace}\n span={selectedSpan}\n onCloseBtnClick={() => setSelectedSpan(undefined)}\n />\n </Box>\n </>\n )}\n </Stack>\n );\n}\n"],"names":["useMemo","useRef","useState","Box","Stack","useTheme","MiniGanttChart","DetailPane","GanttTable","GanttTableProvider","ResizableDivider","getTraceModel","TracingGanttChart","props","options","attributeLinks","trace","otlpTrace","theme","e","Error","viewport","setViewport","startTimeUnixMs","endTimeUnixMs","selectedSpan","setSelectedSpan","undefined","ganttChart","tableWidth","setTableWidth","gap","ref","direction","sx","height","minHeight","flexGrow","onSpanClick","parentRef","spacing","parseInt","onMove","width","overflow","span","onCloseBtnClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAuBA,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,GAAG,EAAEC,KAAK,EAAEC,QAAQ,QAAQ,gBAAgB;AAGrD,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,UAAU,QAAQ,0BAA0B;AAErD,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,kBAAkB,QAAQ,kCAAkC;AACrE,SAASC,gBAAgB,QAAQ,gCAAgC;AAEjE,SAASC,aAAa,QAAc,UAAU;AAQ9C;;;;;CAKC,GACD,OAAO,SAASC,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,OAAO,EAAEC,cAAc,EAAEC,OAAOC,SAAS,EAAE,GAAGJ;IAEtD,MAAMK,QAAQb;IACd,MAAMW,QAAQhB,QAAQ;QACpB,IAAI;YACF,OAAOW,cAAcM;QACvB,EAAE,OAAOE,GAAG;YACV,MAAM,IAAIC,MAAM,CAAC,8BAA8B,EAAED,GAAG;QACtD;IACF,GAAG;QAACF;KAAU;IACd,MAAM,CAACI,UAAUC,YAAY,GAAGpB,SAAmB;QACjDqB,iBAAiBP,MAAMO,eAAe;QACtCC,eAAeR,MAAMQ,aAAa;IACpC;IACA,MAAM,CAACC,cAAcC,gBAAgB,GAAGxB,SAA2ByB;IAEnE,MAAMC,aAAa3B,OAAuB;IAC1C,iEAAiE;IACjE,yDAAyD;IACzD,MAAM,CAAC4B,YAAYC,cAAc,GAAG5B,SAAiB;IACrD,MAAM6B,MAAM;IAEZ,qBACE,MAAC3B;QAAM4B,KAAKJ;QAAYK,WAAU;QAAMC,IAAI;YAAEC,QAAQ;YAAQC,WAAW;YAASL;QAAI;;0BACpF,MAAC3B;gBAAM8B,IAAI;oBAAEG,UAAU;oBAAGN;gBAAI;;kCAC5B,KAACzB;wBAAeQ,SAASA;wBAASE,OAAOA;wBAAOK,UAAUA;wBAAUC,aAAaA;;kCACjF,KAACb;kCACC,cAAA,KAACD;4BACCM,SAASA;4BACTE,OAAOA;4BACPK,UAAUA;4BACVI,cAAcA;4BACda,aAAaZ;;;;;YAIlBD,8BACC;;kCACE,KAACf;wBAAiB6B,WAAWX;wBAAYY,SAASC,SAASvB,MAAMsB,OAAO,CAACT;wBAAOW,QAAQZ;;kCACxF,KAAC3B;wBAAI+B,IAAI;4BAAES,OAAO,GAAG,AAAC,CAAA,IAAId,UAAS,IAAK,IAAI,CAAC,CAAC;4BAAEe,UAAU;wBAAO;kCAC/D,cAAA,KAACrC;4BACCQ,gBAAgBA;4BAChBC,OAAOA;4BACP6B,MAAMpB;4BACNqB,iBAAiB,IAAMpB,gBAAgBC;;;;;;;AAOrD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Return a consistent color for (name, error) tuple
3
+ */
4
+ export declare function getConsistentColor(name: string, error: boolean): string;
5
+ export declare function getConsistentCategoricalColor(name: string, error: boolean, categoricalPalette: string[], errorPalette: string[]): string;
6
+ //# sourceMappingURL=palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../src/TracingGanttChart/palette.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAQvE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,kBAAkB,EAAE,MAAM,EAAE,EAC5B,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,CAaR"}
@@ -0,0 +1,64 @@
1
+ // Copyright 2024 The Perses 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
+ import ColorHash from 'color-hash';
14
+ // Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
15
+ // More info: https://github.com/zenozeng/color-hash#custom-hue
16
+ // Picked min of 20 and max of 360 to exclude common threshold colors (red).
17
+ // Items with "error" in them will always be generated as red.
18
+ const ERROR_HUE_CUTOFF = 20;
19
+ const colorGenerator = new ColorHash({
20
+ hue: {
21
+ min: ERROR_HUE_CUTOFF,
22
+ max: 360
23
+ }
24
+ });
25
+ const redColorGenerator = new ColorHash({
26
+ hue: {
27
+ min: 0,
28
+ max: ERROR_HUE_CUTOFF
29
+ }
30
+ });
31
+ function computeConsistentColor(name, error) {
32
+ const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
33
+ const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
34
+ const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
35
+ return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
36
+ }
37
+ // To check whether a color has already been generated for a given string.
38
+ // TODO: Predefined color aliases will be defined here
39
+ const colorLookup = {};
40
+ /**
41
+ * Return a consistent color for (name, error) tuple
42
+ */ export function getConsistentColor(name, error) {
43
+ const key = `${name}_____${error}`;
44
+ let value = colorLookup[key];
45
+ if (!value) {
46
+ value = computeConsistentColor(name, error);
47
+ colorLookup[key] = value;
48
+ }
49
+ return value;
50
+ }
51
+ export function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
52
+ const palette = error ? errorPalette : categoricalPalette;
53
+ if (palette.length === 0) {
54
+ console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
55
+ return '#000';
56
+ }
57
+ let hash = 0;
58
+ for(let i = 0; i < name.length; i++){
59
+ hash = name.charCodeAt(i) + ((hash << 5) - hash);
60
+ }
61
+ return palette[Math.abs(hash) % palette.length] ?? '#000';
62
+ }
63
+
64
+ //# sourceMappingURL=palette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/TracingGanttChart/palette.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\nexport function getConsistentCategoricalColor(\n name: string,\n error: boolean,\n categoricalPalette: string[],\n errorPalette: string[]\n): string {\n const palette = error ? errorPalette : categoricalPalette;\n if (palette.length === 0) {\n console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');\n return '#000';\n }\n\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash);\n }\n\n return palette[Math.abs(hash) % palette.length] ?? '#000';\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentCategoricalColor","categoricalPalette","errorPalette","palette","length","console","warn","hash","i","charCodeAt","Math","abs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;IAAiB;AAAE;AAEjF,SAASM,uBAAuBC,IAAY,EAAEC,KAAc;IAC1D,MAAM,CAACN,KAAKO,YAAYC,UAAU,GAAGF,QAAQH,kBAAkBM,GAAG,CAACJ,QAAQN,eAAeU,GAAG,CAACJ;IAC9F,MAAMK,oBAAoB,GAAG,AAACH,CAAAA,aAAa,GAAE,EAAGI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7D,MAAMC,mBAAmB,GAAG,AAACJ,CAAAA,YAAY,GAAE,EAAGG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,EAAEX,IAAIW,OAAO,CAAC,GAAG,CAAC,EAAED,kBAAkB,CAAC,EAAEE,iBAAiB,KAAK,CAAC;AAC/E;AAEA,0EAA0E;AAC1E,sDAAsD;AACtD,MAAMC,cAAsC,CAAC;AAE7C;;CAEC,GACD,OAAO,SAASC,mBAAmBT,IAAY,EAAEC,KAAc;IAC7D,MAAMS,MAAM,GAAGV,KAAK,KAAK,EAAEC,OAAO;IAClC,IAAIU,QAAQH,WAAW,CAACE,IAAI;IAC5B,IAAI,CAACC,OAAO;QACVA,QAAQZ,uBAAuBC,MAAMC;QACrCO,WAAW,CAACE,IAAI,GAAGC;IACrB;IACA,OAAOA;AACT;AAEA,OAAO,SAASC,8BACdZ,IAAY,EACZC,KAAc,EACdY,kBAA4B,EAC5BC,YAAsB;IAEtB,MAAMC,UAAUd,QAAQa,eAAeD;IACvC,IAAIE,QAAQC,MAAM,KAAK,GAAG;QACxBC,QAAQC,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAIC,OAAO;IACX,IAAK,IAAIC,IAAI,GAAGA,IAAIpB,KAAKgB,MAAM,EAAEI,IAAK;QACpCD,OAAOnB,KAAKqB,UAAU,CAACD,KAAM,CAAA,AAACD,CAAAA,QAAQ,CAAA,IAAKA,IAAG;IAChD;IAEA,OAAOJ,OAAO,CAACO,KAAKC,GAAG,CAACJ,QAAQJ,QAAQC,MAAM,CAAC,IAAI;AACrD"}
@@ -0,0 +1,45 @@
1
+ import { otlpcommonv1, otlptracev1 } from '@perses-dev/core';
2
+ /** holds the trace and computed properties required for the Gantt chart */
3
+ export interface Trace {
4
+ trace: otlptracev1.TracesData;
5
+ /**
6
+ * if a trace is incomplete (e.g. a parent span has not been received yet),
7
+ * this branch of the span tree will be appended to the root
8
+ */
9
+ rootSpans: Span[];
10
+ startTimeUnixMs: number;
11
+ endTimeUnixMs: number;
12
+ }
13
+ export interface Span {
14
+ resource: Resource;
15
+ scope: otlpcommonv1.InstrumentationScope;
16
+ parentSpan?: Span;
17
+ /** child spans, sorted by startTime */
18
+ childSpans: Span[];
19
+ traceId: string;
20
+ spanId: string;
21
+ parentSpanId?: string;
22
+ name: string;
23
+ kind?: string;
24
+ startTimeUnixMs: number;
25
+ endTimeUnixMs: number;
26
+ attributes: otlpcommonv1.KeyValue[];
27
+ events: Event[];
28
+ status: otlptracev1.Status;
29
+ }
30
+ export interface Resource {
31
+ serviceName?: string;
32
+ attributes: otlpcommonv1.KeyValue[];
33
+ }
34
+ export interface Event {
35
+ timeUnixMs: number;
36
+ name: string;
37
+ attributes: otlpcommonv1.KeyValue[];
38
+ }
39
+ /**
40
+ * getTraceModel builds a tree of spans from an OTLP trace,
41
+ * and precomputes common fields, for example the start and end time of a trace.
42
+ * Time complexity: O(2n)
43
+ */
44
+ export declare function getTraceModel(trace: otlptracev1.TracesData): Trace;
45
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../src/TracingGanttChart/trace.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAkB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG7E,2EAA2E;AAC3E,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC;IAE9B;;;OAGG;IACH,SAAS,EAAE,IAAI,EAAE,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,YAAY,CAAC,oBAAoB,CAAC;IACzC,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,uCAAuC;IACvC,UAAU,EAAE,IAAI,EAAE,CAAC;IAEnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC;IACpC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,KAAK;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,CAAC,UAAU,GAAG,KAAK,CAmDlE"}
@@ -0,0 +1,109 @@
1
+ // Copyright 2024 The Perses 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
+ import { sortedIndexBy } from 'lodash';
14
+ /**
15
+ * getTraceModel builds a tree of spans from an OTLP trace,
16
+ * and precomputes common fields, for example the start and end time of a trace.
17
+ * Time complexity: O(2n)
18
+ */ export function getTraceModel(trace) {
19
+ // first pass: build lookup table <spanId, Span> and compute min/max
20
+ const lookup = new Map();
21
+ const rootSpans = [];
22
+ let startTimeUnixMs = 0;
23
+ let endTimeUnixMs = 0;
24
+ for (const resourceSpan of trace.resourceSpans){
25
+ const resource = parseResource(resourceSpan.resource);
26
+ for (const scopeSpan of resourceSpan.scopeSpans){
27
+ const scope = parseScope(scopeSpan.scope);
28
+ for (const otelSpan of scopeSpan.spans){
29
+ const span = {
30
+ resource,
31
+ scope,
32
+ childSpans: [],
33
+ ...parseSpan(otelSpan)
34
+ };
35
+ lookup.set(otelSpan.spanId, span);
36
+ if (startTimeUnixMs === 0 || span.startTimeUnixMs < startTimeUnixMs) {
37
+ startTimeUnixMs = span.startTimeUnixMs;
38
+ }
39
+ if (endTimeUnixMs === 0 || span.endTimeUnixMs > endTimeUnixMs) {
40
+ endTimeUnixMs = span.endTimeUnixMs;
41
+ }
42
+ }
43
+ }
44
+ }
45
+ // second pass: build tree based on parentSpanId property
46
+ for (const [, span] of lookup){
47
+ if (!span.parentSpanId) {
48
+ rootSpans.push(span);
49
+ continue;
50
+ }
51
+ const parent = lookup.get(span.parentSpanId);
52
+ if (!parent) {
53
+ console.trace(`span ${span.spanId} has parent ${span.parentSpanId} which has not been received yet`);
54
+ rootSpans.push(span);
55
+ continue;
56
+ }
57
+ span.parentSpan = parent;
58
+ const insertChildSpanAt = sortedIndexBy(parent.childSpans, span, (s)=>s.startTimeUnixMs);
59
+ parent.childSpans.splice(insertChildSpanAt, 0, span);
60
+ }
61
+ return {
62
+ trace,
63
+ rootSpans,
64
+ startTimeUnixMs,
65
+ endTimeUnixMs
66
+ };
67
+ }
68
+ function parseResource(resource) {
69
+ let serviceName = 'unknown';
70
+ for (const attr of resource?.attributes ?? []){
71
+ if (attr.key === 'service.name' && 'stringValue' in attr.value) {
72
+ serviceName = attr.value.stringValue;
73
+ break;
74
+ }
75
+ }
76
+ return {
77
+ serviceName,
78
+ attributes: resource?.attributes ?? []
79
+ };
80
+ }
81
+ function parseScope(scope) {
82
+ return scope ?? {};
83
+ }
84
+ /**
85
+ * parseSpan parses the Span API type to the internal representation
86
+ * i.e. convert strings to numbers etc.
87
+ */ function parseSpan(span) {
88
+ return {
89
+ traceId: span.traceId,
90
+ spanId: span.spanId,
91
+ parentSpanId: span.parentSpanId,
92
+ name: span.name,
93
+ kind: span.kind,
94
+ startTimeUnixMs: parseInt(span.startTimeUnixNano) * 1e-6,
95
+ endTimeUnixMs: parseInt(span.endTimeUnixNano) * 1e-6,
96
+ attributes: span.attributes ?? [],
97
+ events: (span.events ?? []).map(parseEvent),
98
+ status: span.status ?? {}
99
+ };
100
+ }
101
+ function parseEvent(event) {
102
+ return {
103
+ timeUnixMs: parseInt(event.timeUnixNano) * 1e-6,
104
+ name: event.name,
105
+ attributes: event.attributes ?? []
106
+ };
107
+ }
108
+
109
+ //# sourceMappingURL=trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/TracingGanttChart/trace.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { otlpcommonv1, otlpresourcev1, otlptracev1 } from '@perses-dev/core';\nimport { sortedIndexBy } from 'lodash';\n\n/** holds the trace and computed properties required for the Gantt chart */\nexport interface Trace {\n trace: otlptracev1.TracesData;\n\n /**\n * if a trace is incomplete (e.g. a parent span has not been received yet),\n * this branch of the span tree will be appended to the root\n */\n rootSpans: Span[];\n startTimeUnixMs: number;\n endTimeUnixMs: number;\n}\n\nexport interface Span {\n resource: Resource;\n scope: otlpcommonv1.InstrumentationScope;\n parentSpan?: Span;\n /** child spans, sorted by startTime */\n childSpans: Span[];\n\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n name: string;\n kind?: string;\n startTimeUnixMs: number;\n endTimeUnixMs: number;\n attributes: otlpcommonv1.KeyValue[];\n events: Event[];\n status: otlptracev1.Status;\n}\n\nexport interface Resource {\n serviceName?: string;\n attributes: otlpcommonv1.KeyValue[];\n}\n\nexport interface Event {\n timeUnixMs: number;\n name: string;\n attributes: otlpcommonv1.KeyValue[];\n}\n\n/**\n * getTraceModel builds a tree of spans from an OTLP trace,\n * and precomputes common fields, for example the start and end time of a trace.\n * Time complexity: O(2n)\n */\nexport function getTraceModel(trace: otlptracev1.TracesData): Trace {\n // first pass: build lookup table <spanId, Span> and compute min/max\n const lookup = new Map<string, Span>();\n const rootSpans: Span[] = [];\n let startTimeUnixMs: number = 0;\n let endTimeUnixMs: number = 0;\n for (const resourceSpan of trace.resourceSpans) {\n const resource = parseResource(resourceSpan.resource);\n\n for (const scopeSpan of resourceSpan.scopeSpans) {\n const scope = parseScope(scopeSpan.scope);\n\n for (const otelSpan of scopeSpan.spans) {\n const span: Span = {\n resource,\n scope,\n childSpans: [],\n ...parseSpan(otelSpan),\n };\n lookup.set(otelSpan.spanId, span);\n\n if (startTimeUnixMs === 0 || span.startTimeUnixMs < startTimeUnixMs) {\n startTimeUnixMs = span.startTimeUnixMs;\n }\n if (endTimeUnixMs === 0 || span.endTimeUnixMs > endTimeUnixMs) {\n endTimeUnixMs = span.endTimeUnixMs;\n }\n }\n }\n }\n\n // second pass: build tree based on parentSpanId property\n for (const [, span] of lookup) {\n if (!span.parentSpanId) {\n rootSpans.push(span);\n continue;\n }\n\n const parent = lookup.get(span.parentSpanId);\n if (!parent) {\n console.trace(`span ${span.spanId} has parent ${span.parentSpanId} which has not been received yet`);\n rootSpans.push(span);\n continue;\n }\n\n span.parentSpan = parent;\n const insertChildSpanAt = sortedIndexBy(parent.childSpans, span, (s) => s.startTimeUnixMs);\n parent.childSpans.splice(insertChildSpanAt, 0, span);\n }\n\n return { trace, rootSpans, startTimeUnixMs, endTimeUnixMs };\n}\n\nfunction parseResource(resource?: otlpresourcev1.Resource): Resource {\n let serviceName = 'unknown';\n for (const attr of resource?.attributes ?? []) {\n if (attr.key === 'service.name' && 'stringValue' in attr.value) {\n serviceName = attr.value.stringValue;\n break;\n }\n }\n\n return {\n serviceName,\n attributes: resource?.attributes ?? [],\n };\n}\n\nfunction parseScope(scope?: otlpcommonv1.InstrumentationScope): otlpcommonv1.InstrumentationScope {\n return scope ?? {};\n}\n\n/**\n * parseSpan parses the Span API type to the internal representation\n * i.e. convert strings to numbers etc.\n */\nfunction parseSpan(span: otlptracev1.Span): Omit<Span, 'resource' | 'scope' | 'childSpans'> {\n return {\n traceId: span.traceId,\n spanId: span.spanId,\n parentSpanId: span.parentSpanId,\n name: span.name,\n kind: span.kind,\n startTimeUnixMs: parseInt(span.startTimeUnixNano) * 1e-6, // convert to milliseconds because JS cannot handle numbers larger than 9007199254740991\n endTimeUnixMs: parseInt(span.endTimeUnixNano) * 1e-6,\n attributes: span.attributes ?? [],\n events: (span.events ?? []).map(parseEvent),\n status: span.status ?? {},\n };\n}\n\nfunction parseEvent(event: otlptracev1.Event): Event {\n return {\n timeUnixMs: parseInt(event.timeUnixNano) * 1e-6, // convert to milliseconds because JS cannot handle numbers larger than 9007199254740991\n name: event.name,\n attributes: event.attributes ?? [],\n };\n}\n"],"names":["sortedIndexBy","getTraceModel","trace","lookup","Map","rootSpans","startTimeUnixMs","endTimeUnixMs","resourceSpan","resourceSpans","resource","parseResource","scopeSpan","scopeSpans","scope","parseScope","otelSpan","spans","span","childSpans","parseSpan","set","spanId","parentSpanId","push","parent","get","console","parentSpan","insertChildSpanAt","s","splice","serviceName","attr","attributes","key","value","stringValue","traceId","name","kind","parseInt","startTimeUnixNano","endTimeUnixNano","events","map","parseEvent","status","event","timeUnixMs","timeUnixNano"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,aAAa,QAAQ,SAAS;AA6CvC;;;;CAIC,GACD,OAAO,SAASC,cAAcC,KAA6B;IACzD,oEAAoE;IACpE,MAAMC,SAAS,IAAIC;IACnB,MAAMC,YAAoB,EAAE;IAC5B,IAAIC,kBAA0B;IAC9B,IAAIC,gBAAwB;IAC5B,KAAK,MAAMC,gBAAgBN,MAAMO,aAAa,CAAE;QAC9C,MAAMC,WAAWC,cAAcH,aAAaE,QAAQ;QAEpD,KAAK,MAAME,aAAaJ,aAAaK,UAAU,CAAE;YAC/C,MAAMC,QAAQC,WAAWH,UAAUE,KAAK;YAExC,KAAK,MAAME,YAAYJ,UAAUK,KAAK,CAAE;gBACtC,MAAMC,OAAa;oBACjBR;oBACAI;oBACAK,YAAY,EAAE;oBACd,GAAGC,UAAUJ,SAAS;gBACxB;gBACAb,OAAOkB,GAAG,CAACL,SAASM,MAAM,EAAEJ;gBAE5B,IAAIZ,oBAAoB,KAAKY,KAAKZ,eAAe,GAAGA,iBAAiB;oBACnEA,kBAAkBY,KAAKZ,eAAe;gBACxC;gBACA,IAAIC,kBAAkB,KAAKW,KAAKX,aAAa,GAAGA,eAAe;oBAC7DA,gBAAgBW,KAAKX,aAAa;gBACpC;YACF;QACF;IACF;IAEA,yDAAyD;IACzD,KAAK,MAAM,GAAGW,KAAK,IAAIf,OAAQ;QAC7B,IAAI,CAACe,KAAKK,YAAY,EAAE;YACtBlB,UAAUmB,IAAI,CAACN;YACf;QACF;QAEA,MAAMO,SAAStB,OAAOuB,GAAG,CAACR,KAAKK,YAAY;QAC3C,IAAI,CAACE,QAAQ;YACXE,QAAQzB,KAAK,CAAC,CAAC,KAAK,EAAEgB,KAAKI,MAAM,CAAC,YAAY,EAAEJ,KAAKK,YAAY,CAAC,gCAAgC,CAAC;YACnGlB,UAAUmB,IAAI,CAACN;YACf;QACF;QAEAA,KAAKU,UAAU,GAAGH;QAClB,MAAMI,oBAAoB7B,cAAcyB,OAAON,UAAU,EAAED,MAAM,CAACY,IAAMA,EAAExB,eAAe;QACzFmB,OAAON,UAAU,CAACY,MAAM,CAACF,mBAAmB,GAAGX;IACjD;IAEA,OAAO;QAAEhB;QAAOG;QAAWC;QAAiBC;IAAc;AAC5D;AAEA,SAASI,cAAcD,QAAkC;IACvD,IAAIsB,cAAc;IAClB,KAAK,MAAMC,QAAQvB,UAAUwB,cAAc,EAAE,CAAE;QAC7C,IAAID,KAAKE,GAAG,KAAK,kBAAkB,iBAAiBF,KAAKG,KAAK,EAAE;YAC9DJ,cAAcC,KAAKG,KAAK,CAACC,WAAW;YACpC;QACF;IACF;IAEA,OAAO;QACLL;QACAE,YAAYxB,UAAUwB,cAAc,EAAE;IACxC;AACF;AAEA,SAASnB,WAAWD,KAAyC;IAC3D,OAAOA,SAAS,CAAC;AACnB;AAEA;;;CAGC,GACD,SAASM,UAAUF,IAAsB;IACvC,OAAO;QACLoB,SAASpB,KAAKoB,OAAO;QACrBhB,QAAQJ,KAAKI,MAAM;QACnBC,cAAcL,KAAKK,YAAY;QAC/BgB,MAAMrB,KAAKqB,IAAI;QACfC,MAAMtB,KAAKsB,IAAI;QACflC,iBAAiBmC,SAASvB,KAAKwB,iBAAiB,IAAI;QACpDnC,eAAekC,SAASvB,KAAKyB,eAAe,IAAI;QAChDT,YAAYhB,KAAKgB,UAAU,IAAI,EAAE;QACjCU,QAAQ,AAAC1B,CAAAA,KAAK0B,MAAM,IAAI,EAAE,AAAD,EAAGC,GAAG,CAACC;QAChCC,QAAQ7B,KAAK6B,MAAM,IAAI,CAAC;IAC1B;AACF;AAEA,SAASD,WAAWE,KAAwB;IAC1C,OAAO;QACLC,YAAYR,SAASO,MAAME,YAAY,IAAI;QAC3CX,MAAMS,MAAMT,IAAI;QAChBL,YAAYc,MAAMd,UAAU,IAAI,EAAE;IACpC;AACF"}
@@ -0,0 +1,18 @@
1
+ import { PersesChartsTheme } from '@perses-dev/components';
2
+ import { Theme } from '@mui/material';
3
+ import { Span } from './trace';
4
+ /**
5
+ * Viewport contains the current zoom, i.e. which timeframe of the trace should be visible
6
+ */
7
+ export interface Viewport {
8
+ startTimeUnixMs: number;
9
+ endTimeUnixMs: number;
10
+ }
11
+ /** minimum span width, i.e. increase width if the calculated width is too small to be visible */
12
+ export declare const minSpanWidthPx = 2;
13
+ export declare const rowHeight = "2rem";
14
+ export declare const spanHasError: (span: Span) => boolean;
15
+ export declare function getServiceColor(muiTheme: Theme, chartsTheme: PersesChartsTheme, paletteMode: 'auto' | 'categorical' | undefined, serviceName: string, error?: boolean): string;
16
+ export declare function getSpanColor(muiTheme: Theme, chartsTheme: PersesChartsTheme, paletteMode: 'auto' | 'categorical' | undefined, span: Span): string;
17
+ export declare function formatDuration(timeMs: number): string;
18
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/TracingGanttChart/utils.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,iGAAiG;AACjG,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,YAAY,GAAI,MAAM,IAAI,KAAG,OAA4D,CAAC;AAEvG,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,EAC/C,WAAW,EAAE,MAAM,EACnB,KAAK,UAAQ,GACZ,MAAM,CAYR;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,EAC/C,IAAI,EAAE,IAAI,GACT,MAAM,CAER;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQrD"}
@@ -0,0 +1,48 @@
1
+ // Copyright 2024 The Perses 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
+ import { otlptracev1 } from '@perses-dev/core';
14
+ import { getConsistentCategoricalColor, getConsistentColor } from './palette';
15
+ /** minimum span width, i.e. increase width if the calculated width is too small to be visible */ export const minSpanWidthPx = 2;
16
+ export const rowHeight = '2rem';
17
+ export const spanHasError = (span)=>span.status?.code === otlptracev1.StatusCodeError;
18
+ export function getServiceColor(muiTheme, chartsTheme, paletteMode, serviceName, error = false) {
19
+ switch(paletteMode){
20
+ case 'categorical':
21
+ {
22
+ // ECharts type for color is not always an array but it is always an array in ChartsProvider
23
+ const categoricalPalette = chartsTheme.echartsTheme.color;
24
+ const errorPalette = [
25
+ muiTheme.palette.error.light,
26
+ muiTheme.palette.error.main,
27
+ muiTheme.palette.error.dark
28
+ ];
29
+ return getConsistentCategoricalColor(serviceName, error, categoricalPalette, errorPalette);
30
+ }
31
+ default:
32
+ return getConsistentColor(serviceName, error);
33
+ }
34
+ }
35
+ export function getSpanColor(muiTheme, chartsTheme, paletteMode, span) {
36
+ return getServiceColor(muiTheme, chartsTheme, paletteMode, span.resource.serviceName ?? '', spanHasError(span));
37
+ }
38
+ export function formatDuration(timeMs) {
39
+ if (timeMs < 1) {
40
+ return `${Math.round(timeMs * 1000)}μs`;
41
+ }
42
+ if (timeMs < 1000) {
43
+ return `${+timeMs.toFixed(2)}ms`;
44
+ }
45
+ return `${+(timeMs / 1000).toFixed(2)}s`;
46
+ }
47
+
48
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/TracingGanttChart/utils.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PersesChartsTheme } from '@perses-dev/components';\nimport { Theme } from '@mui/material';\nimport { otlptracev1 } from '@perses-dev/core';\nimport { getConsistentCategoricalColor, getConsistentColor } from './palette';\nimport { Span } from './trace';\n\n/**\n * Viewport contains the current zoom, i.e. which timeframe of the trace should be visible\n */\nexport interface Viewport {\n startTimeUnixMs: number;\n endTimeUnixMs: number;\n}\n\n/** minimum span width, i.e. increase width if the calculated width is too small to be visible */\nexport const minSpanWidthPx = 2;\nexport const rowHeight = '2rem';\nexport const spanHasError = (span: Span): boolean => span.status?.code === otlptracev1.StatusCodeError;\n\nexport function getServiceColor(\n muiTheme: Theme,\n chartsTheme: PersesChartsTheme,\n paletteMode: 'auto' | 'categorical' | undefined,\n serviceName: string,\n error = false\n): string {\n switch (paletteMode) {\n case 'categorical': {\n // ECharts type for color is not always an array but it is always an array in ChartsProvider\n const categoricalPalette = chartsTheme.echartsTheme.color as string[];\n const errorPalette = [muiTheme.palette.error.light, muiTheme.palette.error.main, muiTheme.palette.error.dark];\n return getConsistentCategoricalColor(serviceName, error, categoricalPalette, errorPalette);\n }\n\n default:\n return getConsistentColor(serviceName, error);\n }\n}\n\nexport function getSpanColor(\n muiTheme: Theme,\n chartsTheme: PersesChartsTheme,\n paletteMode: 'auto' | 'categorical' | undefined,\n span: Span\n): string {\n return getServiceColor(muiTheme, chartsTheme, paletteMode, span.resource.serviceName ?? '', spanHasError(span));\n}\n\nexport function formatDuration(timeMs: number): string {\n if (timeMs < 1) {\n return `${Math.round(timeMs * 1000)}μs`;\n }\n if (timeMs < 1000) {\n return `${+timeMs.toFixed(2)}ms`;\n }\n return `${+(timeMs / 1000).toFixed(2)}s`;\n}\n"],"names":["otlptracev1","getConsistentCategoricalColor","getConsistentColor","minSpanWidthPx","rowHeight","spanHasError","span","status","code","StatusCodeError","getServiceColor","muiTheme","chartsTheme","paletteMode","serviceName","error","categoricalPalette","echartsTheme","color","errorPalette","palette","light","main","dark","getSpanColor","resource","formatDuration","timeMs","Math","round","toFixed"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,6BAA6B,EAAEC,kBAAkB,QAAQ,YAAY;AAW9E,+FAA+F,GAC/F,OAAO,MAAMC,iBAAiB,EAAE;AAChC,OAAO,MAAMC,YAAY,OAAO;AAChC,OAAO,MAAMC,eAAe,CAACC,OAAwBA,KAAKC,MAAM,EAAEC,SAASR,YAAYS,eAAe,CAAC;AAEvG,OAAO,SAASC,gBACdC,QAAe,EACfC,WAA8B,EAC9BC,WAA+C,EAC/CC,WAAmB,EACnBC,QAAQ,KAAK;IAEb,OAAQF;QACN,KAAK;YAAe;gBAClB,4FAA4F;gBAC5F,MAAMG,qBAAqBJ,YAAYK,YAAY,CAACC,KAAK;gBACzD,MAAMC,eAAe;oBAACR,SAASS,OAAO,CAACL,KAAK,CAACM,KAAK;oBAAEV,SAASS,OAAO,CAACL,KAAK,CAACO,IAAI;oBAAEX,SAASS,OAAO,CAACL,KAAK,CAACQ,IAAI;iBAAC;gBAC7G,OAAOtB,8BAA8Ba,aAAaC,OAAOC,oBAAoBG;YAC/E;QAEA;YACE,OAAOjB,mBAAmBY,aAAaC;IAC3C;AACF;AAEA,OAAO,SAASS,aACdb,QAAe,EACfC,WAA8B,EAC9BC,WAA+C,EAC/CP,IAAU;IAEV,OAAOI,gBAAgBC,UAAUC,aAAaC,aAAaP,KAAKmB,QAAQ,CAACX,WAAW,IAAI,IAAIT,aAAaC;AAC3G;AAEA,OAAO,SAASoB,eAAeC,MAAc;IAC3C,IAAIA,SAAS,GAAG;QACd,OAAO,GAAGC,KAAKC,KAAK,CAACF,SAAS,MAAM,EAAE,CAAC;IACzC;IACA,IAAIA,SAAS,MAAM;QACjB,OAAO,GAAG,CAACA,OAAOG,OAAO,CAAC,GAAG,EAAE,CAAC;IAClC;IACA,OAAO,GAAG,CAAC,AAACH,CAAAA,SAAS,IAAG,EAAGG,OAAO,CAAC,GAAG,CAAC,CAAC;AAC1C"}
@@ -0,0 +1,5 @@
1
+ import { PanelPlugin } from '@perses-dev/plugin-system';
2
+ import { TracingGanttChartOptions } from './gantt-chart-model';
3
+ import { TracingGanttChartPanelProps } from './TracingGanttChartPanel';
4
+ export declare const TracingGanttChart: PanelPlugin<TracingGanttChartOptions, TracingGanttChartPanelProps>;
5
+ //# sourceMappingURL=TracingGanttChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TracingGanttChart.d.ts","sourceRoot":"","sources":["../../src/TracingGanttChart.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAyC,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AACtG,OAAO,EAA0B,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE/F,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,wBAAwB,EAAE,2BAA2B,CAIhG,CAAC"}
@@ -0,0 +1,23 @@
1
+ // Copyright 2024 The Perses 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
+ import { createInitialTracingGanttChartOptions } from './gantt-chart-model';
14
+ import { TracingGanttChartPanel } from './TracingGanttChartPanel';
15
+ export const TracingGanttChart = {
16
+ PanelComponent: TracingGanttChartPanel,
17
+ supportedQueryTypes: [
18
+ 'TraceQuery'
19
+ ],
20
+ createInitialOptions: createInitialTracingGanttChartOptions
21
+ };
22
+
23
+ //# sourceMappingURL=TracingGanttChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TracingGanttChart.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelPlugin } from '@perses-dev/plugin-system';\nimport { createInitialTracingGanttChartOptions, TracingGanttChartOptions } from './gantt-chart-model';\nimport { TracingGanttChartPanel, TracingGanttChartPanelProps } from './TracingGanttChartPanel';\n\nexport const TracingGanttChart: PanelPlugin<TracingGanttChartOptions, TracingGanttChartPanelProps> = {\n PanelComponent: TracingGanttChartPanel,\n supportedQueryTypes: ['TraceQuery'],\n createInitialOptions: createInitialTracingGanttChartOptions,\n};\n"],"names":["createInitialTracingGanttChartOptions","TracingGanttChartPanel","TracingGanttChart","PanelComponent","supportedQueryTypes","createInitialOptions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,qCAAqC,QAAkC,sBAAsB;AACtG,SAASC,sBAAsB,QAAqC,2BAA2B;AAE/F,OAAO,MAAMC,oBAAwF;IACnGC,gBAAgBF;IAChBG,qBAAqB;QAAC;KAAa;IACnCC,sBAAsBL;AACxB,EAAE"}
@@ -0,0 +1,17 @@
1
+ import { PanelProps } from '@perses-dev/plugin-system';
2
+ import { ReactElement } from 'react';
3
+ import { TraceData } from '@perses-dev/core';
4
+ import { TracingGanttChartOptions } from './gantt-chart-model';
5
+ import { AttributeLinks } from './TracingGanttChart/DetailPane/Attributes';
6
+ export interface TracingGanttChartPanelProps extends PanelProps<TracingGanttChartOptions, TraceData> {
7
+ /**
8
+ * Allows custom links for each attribute in the detail pane.
9
+ * Example:
10
+ * {
11
+ * 'k8s.pod.name': (attrs) => `/my/console/namespace/${attrs['k8s.namespace.name']?.stringValue}/${attrs['k8s.pod.name']?.stringValue}/detail`
12
+ * }
13
+ */
14
+ attributeLinks?: AttributeLinks;
15
+ }
16
+ export declare function TracingGanttChartPanel(props: TracingGanttChartPanelProps): ReactElement;
17
+ //# sourceMappingURL=TracingGanttChartPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TracingGanttChartPanel.d.ts","sourceRoot":"","sources":["../../src/TracingGanttChartPanel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,MAAM,WAAW,2BAA4B,SAAQ,UAAU,CAAC,wBAAwB,EAAE,SAAS,CAAC;IAClG;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,YAAY,CAmBvF"}
@@ -0,0 +1,45 @@
1
+ // Copyright 2024 The Perses 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { NoDataOverlay, TextOverlay, useChartsTheme } from '@perses-dev/components';
15
+ import { Box } from '@mui/material';
16
+ import { TracingGanttChart } from './TracingGanttChart/TracingGanttChart';
17
+ export function TracingGanttChartPanel(props) {
18
+ const { spec, queryResults, attributeLinks } = props;
19
+ const chartsTheme = useChartsTheme();
20
+ const contentPadding = chartsTheme.container.padding.default;
21
+ if (queryResults.length > 1) {
22
+ return /*#__PURE__*/ _jsx(TextOverlay, {
23
+ message: "This panel does not support more than one query."
24
+ });
25
+ }
26
+ const trace = queryResults[0]?.data.trace;
27
+ if (!trace) {
28
+ return /*#__PURE__*/ _jsx(NoDataOverlay, {
29
+ resource: "trace"
30
+ });
31
+ }
32
+ return /*#__PURE__*/ _jsx(Box, {
33
+ sx: {
34
+ height: '100%',
35
+ padding: `${contentPadding}px`
36
+ },
37
+ children: /*#__PURE__*/ _jsx(TracingGanttChart, {
38
+ options: spec,
39
+ attributeLinks: attributeLinks,
40
+ trace: trace
41
+ })
42
+ });
43
+ }
44
+
45
+ //# sourceMappingURL=TracingGanttChartPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/TracingGanttChartPanel.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelProps } from '@perses-dev/plugin-system';\nimport { NoDataOverlay, TextOverlay, useChartsTheme } from '@perses-dev/components';\nimport { Box } from '@mui/material';\nimport { ReactElement } from 'react';\nimport { TraceData } from '@perses-dev/core';\nimport { TracingGanttChartOptions } from './gantt-chart-model';\nimport { TracingGanttChart } from './TracingGanttChart/TracingGanttChart';\nimport { AttributeLinks } from './TracingGanttChart/DetailPane/Attributes';\n\nexport interface TracingGanttChartPanelProps extends PanelProps<TracingGanttChartOptions, TraceData> {\n /**\n * Allows custom links for each attribute in the detail pane.\n * Example:\n * {\n * 'k8s.pod.name': (attrs) => `/my/console/namespace/${attrs['k8s.namespace.name']?.stringValue}/${attrs['k8s.pod.name']?.stringValue}/detail`\n * }\n */\n attributeLinks?: AttributeLinks;\n}\n\nexport function TracingGanttChartPanel(props: TracingGanttChartPanelProps): ReactElement {\n const { spec, queryResults, attributeLinks } = props;\n const chartsTheme = useChartsTheme();\n const contentPadding = chartsTheme.container.padding.default;\n\n if (queryResults.length > 1) {\n return <TextOverlay message=\"This panel does not support more than one query.\" />;\n }\n\n const trace = queryResults[0]?.data.trace;\n if (!trace) {\n return <NoDataOverlay resource=\"trace\" />;\n }\n\n return (\n <Box sx={{ height: '100%', padding: `${contentPadding}px` }}>\n <TracingGanttChart options={spec} attributeLinks={attributeLinks} trace={trace} />\n </Box>\n );\n}\n"],"names":["NoDataOverlay","TextOverlay","useChartsTheme","Box","TracingGanttChart","TracingGanttChartPanel","props","spec","queryResults","attributeLinks","chartsTheme","contentPadding","container","padding","default","length","message","trace","data","resource","sx","height","options"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,aAAa,EAAEC,WAAW,EAAEC,cAAc,QAAQ,yBAAyB;AACpF,SAASC,GAAG,QAAQ,gBAAgB;AAIpC,SAASC,iBAAiB,QAAQ,wCAAwC;AAc1E,OAAO,SAASC,uBAAuBC,KAAkC;IACvE,MAAM,EAAEC,IAAI,EAAEC,YAAY,EAAEC,cAAc,EAAE,GAAGH;IAC/C,MAAMI,cAAcR;IACpB,MAAMS,iBAAiBD,YAAYE,SAAS,CAACC,OAAO,CAACC,OAAO;IAE5D,IAAIN,aAAaO,MAAM,GAAG,GAAG;QAC3B,qBAAO,KAACd;YAAYe,SAAQ;;IAC9B;IAEA,MAAMC,QAAQT,YAAY,CAAC,EAAE,EAAEU,KAAKD;IACpC,IAAI,CAACA,OAAO;QACV,qBAAO,KAACjB;YAAcmB,UAAS;;IACjC;IAEA,qBACE,KAAChB;QAAIiB,IAAI;YAAEC,QAAQ;YAAQR,SAAS,GAAGF,eAAe,EAAE,CAAC;QAAC;kBACxD,cAAA,KAACP;YAAkBkB,SAASf;YAAME,gBAAgBA;YAAgBQ,OAAOA;;;AAG/E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ // Copyright 2024 The Perses 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import ReactDOM from 'react-dom/client';
16
+ const root = ReactDOM.createRoot(document.getElementById('root'));
17
+ root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
+
19
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bootstrap.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,mBAAmB;AAExC,MAAMC,OAAOD,SAASE,UAAU,CAACC,SAASC,cAAc,CAAC;AACzDH,KAAKI,MAAM,eAAC,KAACN,MAAMO,UAAU"}