@perses-dev/tracing-gantt-chart-plugin 0.14.0-beta.7 → 0.14.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/{TracingGanttChart.4f137753.js → TracingGanttChart.d9b59f93.js} +2 -2
- package/__mf/js/async/121.92df80eb.js +2 -0
- package/__mf/js/async/181.1dd3d537.js +43 -0
- package/__mf/js/async/192.f15300f5.js +1 -0
- package/__mf/js/async/2.95b4f6c0.js +1 -0
- package/__mf/js/async/209.fd27698d.js +2 -0
- package/__mf/js/async/235.0675e691.js +1 -0
- package/__mf/js/async/247.24f55530.js +1 -0
- package/__mf/js/async/255.9c3cabe2.js +53 -0
- package/__mf/js/async/274.53fc26a4.js +2 -0
- package/__mf/js/async/356.a870fa96.js +1 -0
- package/__mf/js/async/392.0c76141a.js +2 -0
- package/__mf/js/async/43.4c3c5c0f.js +2 -0
- package/__mf/js/async/{436.3529fc0c.js → 436.ab3ccc6d.js} +2 -2
- package/__mf/js/async/470.c580b0f9.js +2 -0
- package/__mf/js/async/496.fce0470b.js +1 -0
- package/__mf/js/async/587.d494e69b.js +1 -0
- package/__mf/js/async/588.957ec837.js +1 -0
- package/__mf/js/async/616.be150b44.js +1 -0
- package/__mf/js/async/672.f46ddfc3.js +1 -0
- package/__mf/js/async/71.a381e77a.js +1 -0
- package/__mf/js/async/77.c9254c23.js +1 -0
- package/__mf/js/async/873.85d15782.js +1 -0
- package/__mf/js/async/941.f02c6f75.js +2 -0
- package/__mf/js/async/968.5dcb60d0.js +1 -0
- package/__mf/js/async/978.913d8c4f.js +1 -0
- package/__mf/js/async/__federation_expose_TracingGanttChart.d3bb9efc.js +1 -0
- package/__mf/js/async/lib-router.c5a9412b.js +2 -0
- package/__mf/js/{main.2a10c1a4.js → main.9c100c8b.js} +7 -7
- package/lib/TracingGanttChart/GanttTable/ResizableDivider.d.ts +0 -1
- package/lib/TracingGanttChart/GanttTable/ResizableDivider.d.ts.map +1 -1
- package/lib/TracingGanttChart/GanttTable/ResizableDivider.js +4 -1
- package/lib/TracingGanttChart/GanttTable/ResizableDivider.js.map +1 -1
- package/lib/TracingGanttChart/MiniGanttChart/Canvas.js +2 -3
- package/lib/TracingGanttChart/MiniGanttChart/Canvas.js.map +1 -1
- package/lib/TracingGanttChart/TracingGanttChart.d.ts.map +1 -1
- package/lib/TracingGanttChart/TracingGanttChart.js +0 -2
- package/lib/TracingGanttChart/TracingGanttChart.js.map +1 -1
- package/lib/test/convert/jaeger.js +2 -2
- package/lib/test/convert/jaeger.js.map +1 -1
- package/mf-manifest.json +35 -35
- package/mf-stats.json +35 -35
- package/package.json +4 -4
- package/__mf/js/async/121.86585ed6.js +0 -2
- package/__mf/js/async/192.3acb0e0e.js +0 -1
- package/__mf/js/async/2.74366b93.js +0 -1
- package/__mf/js/async/209.4ab02e24.js +0 -2
- package/__mf/js/async/228.ddd50c4b.js +0 -43
- package/__mf/js/async/235.d2b379b9.js +0 -1
- package/__mf/js/async/247.dc6e48cb.js +0 -1
- package/__mf/js/async/274.ff633c2b.js +0 -2
- package/__mf/js/async/356.898949a0.js +0 -1
- package/__mf/js/async/392.83a96981.js +0 -2
- package/__mf/js/async/43.10e346da.js +0 -2
- package/__mf/js/async/470.119370a2.js +0 -2
- package/__mf/js/async/496.31ef7d09.js +0 -1
- package/__mf/js/async/508.1a4aed3e.js +0 -53
- package/__mf/js/async/587.3deafc0b.js +0 -1
- package/__mf/js/async/588.ff3178f6.js +0 -1
- package/__mf/js/async/616.f966554e.js +0 -1
- package/__mf/js/async/672.89eff67f.js +0 -1
- package/__mf/js/async/71.e1596f2e.js +0 -1
- package/__mf/js/async/77.5d74575d.js +0 -1
- package/__mf/js/async/873.0883c868.js +0 -1
- package/__mf/js/async/941.c688c7ce.js +0 -2
- package/__mf/js/async/968.1f4cc5c6.js +0 -1
- package/__mf/js/async/978.5d4e10a3.js +0 -1
- package/__mf/js/async/__federation_expose_TracingGanttChart.99755db8.js +0 -1
- package/__mf/js/async/lib-router.d4727407.js +0 -2
- /package/__mf/css/async/{228.85c2cbf6.css → 181.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.86585ed6.js.LICENSE.txt → 121.92df80eb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{228.ddd50c4b.js.LICENSE.txt → 181.1dd3d537.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{508.1a4aed3e.js.LICENSE.txt → 255.9c3cabe2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.ff633c2b.js.LICENSE.txt → 274.53fc26a4.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.83a96981.js.LICENSE.txt → 392.0c76141a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{43.10e346da.js.LICENSE.txt → 43.4c3c5c0f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{436.3529fc0c.js.LICENSE.txt → 436.ab3ccc6d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.119370a2.js.LICENSE.txt → 470.c580b0f9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.c688c7ce.js.LICENSE.txt → 941.f02c6f75.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.d4727407.js.LICENSE.txt → lib-router.c5a9412b.js.LICENSE.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResizableDivider.d.ts","sourceRoot":"","sources":["../../../../src/TracingGanttChart/GanttTable/ResizableDivider.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAiC,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzE,UAAU,qBAAqB;IAC7B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,
|
|
1
|
+
{"version":3,"file":"ResizableDivider.d.ts","sourceRoot":"","sources":["../../../../src/TracingGanttChart/GanttTable/ResizableDivider.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAiC,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzE,UAAU,qBAAqB;IAC7B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,CA8D3E"}
|
|
@@ -15,11 +15,14 @@ import { Box, styled } from "@mui/material";
|
|
|
15
15
|
import { useEvent } from "@perses-dev/plugin-system";
|
|
16
16
|
import { useEffect, useState } from "react";
|
|
17
17
|
export function ResizableDivider(props) {
|
|
18
|
-
const { parentRef,
|
|
18
|
+
const { parentRef, onMove } = props;
|
|
19
19
|
const [isResizing, setResizing] = useState(false);
|
|
20
|
+
const [spacing, setSpacing] = useState(0);
|
|
20
21
|
const handleMouseDown = (e)=>{
|
|
21
22
|
// disable any default actions (text selection, etc.)
|
|
22
23
|
e.preventDefault();
|
|
24
|
+
// read the flex gap once per drag instead of on every mousemove
|
|
25
|
+
setSpacing(parentRef.current ? parseFloat(getComputedStyle(parentRef.current).columnGap) || 0 : 0);
|
|
23
26
|
setResizing(true);
|
|
24
27
|
};
|
|
25
28
|
// need stable reference for window.removeEventListener() in useEffect() below
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/TracingGanttChart/GanttTable/ResizableDivider.tsx"],"sourcesContent":["// Copyright 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 { Box, styled } from '@mui/material';\nimport { useEvent } from '@perses-dev/plugin-system';\nimport type { MouseEvent as ReactMouseEvent, ReactElement } from 'react';\nimport { useEffect, useState } from 'react';\n\ninterface ResizableDividerProps {\n parentRef: React.RefObject<Element>;\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/TracingGanttChart/GanttTable/ResizableDivider.tsx"],"sourcesContent":["// Copyright 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 { Box, styled } from '@mui/material';\nimport { useEvent } from '@perses-dev/plugin-system';\nimport type { MouseEvent as ReactMouseEvent, ReactElement } from 'react';\nimport { useEffect, useState } from 'react';\n\ninterface ResizableDividerProps {\n parentRef: React.RefObject<Element>;\n onMove: (left: number) => void;\n}\n\nexport function ResizableDivider(props: ResizableDividerProps): ReactElement {\n const { parentRef, onMove } = props;\n const [isResizing, setResizing] = useState(false);\n const [spacing, setSpacing] = useState(0);\n\n const handleMouseDown = (e: ReactMouseEvent): void => {\n // disable any default actions (text selection, etc.)\n e.preventDefault();\n\n // read the flex gap once per drag instead of on every mousemove\n setSpacing(parentRef.current ? parseFloat(getComputedStyle(parentRef.current).columnGap) || 0 : 0);\n setResizing(true);\n };\n\n // need stable reference for window.removeEventListener() in useEffect() below\n const handleMouseMove = useEvent((e: MouseEvent) => {\n if (!parentRef.current) return;\n\n const parentRect = parentRef.current.getBoundingClientRect();\n\n // The parent can be a flex row, for example: [leftPercent] [gap] [divider] [gap] [1-leftPercent].\n // Without considering spacing, leftPercent would be wrong because it ignores the flex gap between the divider and the element.\n const offsetX = e.clientX - parentRect.left + spacing;\n const leftPercent = offsetX / parentRect.width;\n\n if (0.05 <= leftPercent && leftPercent <= 0.95) {\n onMove(leftPercent);\n }\n });\n\n // need stable reference for window.removeEventListener() in useEffect() below\n const handleMouseUp = useEvent(() => {\n setResizing(false);\n });\n\n // capture mouseMove and mouseUp outside the element by attaching them to the window object\n useEffect(() => {\n function startMouseAction(): void {\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('mouseup', handleMouseUp);\n document.body.style.cursor = 'col-resize';\n }\n\n function stopMouseAction(): void {\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('mouseup', handleMouseUp);\n document.body.style.cursor = 'inherit';\n }\n\n if (isResizing) {\n startMouseAction();\n } else {\n stopMouseAction();\n }\n\n return stopMouseAction;\n }, [isResizing, handleMouseMove, handleMouseUp]);\n\n // prevent onClick event when clicking on a divider\n const stopEventPropagation = (e: ReactMouseEvent): void => e.stopPropagation();\n\n return <ResizableDividerBox onMouseDown={handleMouseDown} onClick={stopEventPropagation} />;\n}\n\nconst ResizableDividerBox = styled(Box)(({ theme }) => ({\n position: 'relative',\n width: '1px',\n minWidth: '1px',\n height: '100%',\n backgroundColor: theme.palette.divider,\n cursor: 'col-resize',\n\n // increase clickable area from 1px to 7px\n '&:before': {\n position: 'absolute',\n width: '7px',\n left: '-3px',\n top: 0,\n bottom: 0,\n content: '\" \"',\n zIndex: 1, // without zIndex, the span duration row hides the right side of this element\n },\n}));\n"],"names":["Box","styled","useEvent","useEffect","useState","ResizableDivider","props","parentRef","onMove","isResizing","setResizing","spacing","setSpacing","handleMouseDown","e","preventDefault","current","parseFloat","getComputedStyle","columnGap","handleMouseMove","parentRect","getBoundingClientRect","offsetX","clientX","left","leftPercent","width","handleMouseUp","startMouseAction","window","addEventListener","document","body","style","cursor","stopMouseAction","removeEventListener","stopEventPropagation","stopPropagation","ResizableDividerBox","onMouseDown","onClick","theme","position","minWidth","height","backgroundColor","palette","divider","top","bottom","content","zIndex"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAo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CAACC,MAAM,GAAG;QAC/B;QAEA,IAAI1B,YAAY;YACdoB;QACF,OAAO;YACLO;QACF;QAEA,OAAOA;IACT,GAAG;QAAC3B;QAAYW;QAAiBQ;KAAc;IAE/C,mDAAmD;IACnD,MAAMU,uBAAuB,CAACxB,IAA6BA,EAAEyB,eAAe;IAE5E,qBAAO,KAACC;QAAoBC,aAAa5B;QAAiB6B,SAASJ;;AACrE;AAEA,MAAME,sBAAsBvC,OAAOD,KAAK,CAAC,EAAE2C,KAAK,EAAE,GAAM,CAAA;QACtDC,UAAU;QACVjB,OAAO;QACPkB,UAAU;QACVC,QAAQ;QACRC,iBAAiBJ,MAAMK,OAAO,CAACC,OAAO;QACtCd,QAAQ;QAER,0CAA0C;QAC1C,YAAY;YACVS,UAAU;YACVjB,OAAO;YACPF,MAAM;YACNyB,KAAK;YACLC,QAAQ;YACRC,SAAS;YACTC,QAAQ;QACV;IACF,CAAA"}
|
|
@@ -41,13 +41,12 @@ export function Canvas(props) {
|
|
|
41
41
|
options.visual?.palette?.mode
|
|
42
42
|
]);
|
|
43
43
|
useEffect(()=>{
|
|
44
|
-
if (!canvasRef.current || !width
|
|
44
|
+
if (!canvasRef.current || !width) return;
|
|
45
45
|
const ctx = canvasRef.current.getContext('2d');
|
|
46
46
|
if (!ctx) return;
|
|
47
|
-
drawSpans(ctx, width,
|
|
47
|
+
drawSpans(ctx, width, CANVAS_HEIGHT, trace, spanColorGenerator);
|
|
48
48
|
}, [
|
|
49
49
|
width,
|
|
50
|
-
height,
|
|
51
50
|
trace,
|
|
52
51
|
spanColorGenerator
|
|
53
52
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/TracingGanttChart/MiniGanttChart/Canvas.tsx"],"sourcesContent":["// Copyright 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 { Box, styled, useTheme } from '@mui/material';\nimport { useChartsTheme } from '@perses-dev/components';\nimport { useEvent } from '@perses-dev/plugin-system';\nimport type { MouseEvent as ReactMouseEvent, ReactElement } from 'react';\nimport { useEffect, useRef, useState, useCallback } from 'react';\nimport useResizeObserver from 'use-resize-observer';\n\nimport type { TracingGanttChartOptions } from '../../gantt-chart-model';\nimport { Ticks } from '../Ticks';\nimport type { Span, Trace } from '../trace';\nimport type { Viewport } from '../utils';\nimport { getSpanColor } from '../utils';\nimport { drawSpans } from './draw';\n\nconst CANVAS_HEIGHT = 60;\n\ninterface CanvasProps {\n options: TracingGanttChartOptions;\n trace: Trace;\n viewport: Viewport;\n setViewport: (v: Viewport) => void;\n}\n\ntype MouseState =\n | { type: 'none' }\n | { type: 'resize'; fixedPoint: number }\n | { type: 'drag'; start: number; end: number };\n\nexport function Canvas(props: CanvasProps): ReactElement {\n const { options, trace, viewport, setViewport } = props;\n const muiTheme = useTheme();\n const chartsTheme = useChartsTheme();\n // the <canvas> element must have an absolute width and height to avoid rendering problems\n // the wrapper box is required to get the available dimensions for the <canvas> element\n const { width, ref: wrapperRef } = useResizeObserver();\n const height = CANVAS_HEIGHT;\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const [mouseState, setMouseState] = useState<MouseState>({ type: 'none' });\n\n const traceDuration = trace.endTimeUnixMs - trace.startTimeUnixMs;\n const relativeCutoffLeft = (viewport.startTimeUnixMs - trace.startTimeUnixMs) / traceDuration;\n const relativeCutoffRight = (trace.endTimeUnixMs - viewport.endTimeUnixMs) / traceDuration;\n\n const spanColorGenerator = useCallback(\n (span: Span) => getSpanColor(muiTheme, chartsTheme, options.visual?.palette?.mode, span),\n [muiTheme, chartsTheme, options.visual?.palette?.mode],\n );\n\n useEffect(() => {\n if (!canvasRef.current || !width || !height) return;\n\n const ctx = canvasRef.current.getContext('2d');\n if (!ctx) return;\n\n drawSpans(ctx, width, height, trace, spanColorGenerator);\n }, [width, height, trace, spanColorGenerator]);\n\n const translateCursorToTime = (e: ReactMouseEvent | MouseEvent): number => {\n if (!canvasRef.current || !width) return 0;\n // e.nativeEvent.offsetX doesn't work when sliding over a tick box\n const offsetX = e.clientX - canvasRef.current.getBoundingClientRect().left;\n return trace.startTimeUnixMs + (offsetX / width) * traceDuration;\n };\n\n const handleMouseDown = (e: ReactMouseEvent<HTMLDivElement>): void => {\n e.preventDefault();\n if (!(e.target instanceof HTMLElement)) return;\n\n const isDefaultViewport =\n viewport.startTimeUnixMs === trace.startTimeUnixMs && viewport.endTimeUnixMs === trace.endTimeUnixMs;\n const elem = e.target.dataset['elem'];\n const cursor = translateCursorToTime(e);\n\n if (elem === 'resizerLeft') {\n setMouseState({ type: 'resize', fixedPoint: viewport.endTimeUnixMs });\n } else if (elem === 'resizerRight') {\n setMouseState({ type: 'resize', fixedPoint: viewport.startTimeUnixMs });\n } else if (elem === 'cutoffBox' || isDefaultViewport) {\n setMouseState({ type: 'resize', fixedPoint: cursor });\n setViewport({ startTimeUnixMs: cursor, endTimeUnixMs: cursor });\n } else {\n setMouseState({\n type: 'drag',\n start: cursor - viewport.startTimeUnixMs,\n end: viewport.endTimeUnixMs - cursor,\n });\n }\n };\n\n // need stable reference for window.removeEventListener() in useEffect() below\n const handleMouseMove = useEvent((e: MouseEvent) => {\n e.preventDefault();\n\n switch (mouseState.type) {\n case 'none':\n return;\n\n case 'resize': {\n const pointA = mouseState.fixedPoint;\n const pointB = translateCursorToTime(e);\n\n let start, end;\n if (pointA < pointB) {\n start = pointA;\n end = pointB;\n } else {\n start = pointB;\n end = pointA;\n }\n\n setViewport({\n startTimeUnixMs: Math.max(start, trace.startTimeUnixMs),\n endTimeUnixMs: Math.min(end, trace.endTimeUnixMs),\n });\n return;\n }\n\n case 'drag': {\n // avoid using e.movementX here, as it skips events in chrome,\n // resulting in the mouse pointer moving faster than the viewport box\n const { start, end } = mouseState;\n let cursor = translateCursorToTime(e);\n\n if (cursor - start < trace.startTimeUnixMs) {\n cursor = trace.startTimeUnixMs + start;\n }\n if (cursor + end > trace.endTimeUnixMs) {\n cursor = trace.endTimeUnixMs - end;\n }\n\n setViewport({\n startTimeUnixMs: cursor - start,\n endTimeUnixMs: cursor + end,\n });\n return;\n }\n }\n });\n\n // need stable reference for window.removeEventListener() in useEffect() below\n const handleMouseUp = useEvent((e: MouseEvent) => {\n e.preventDefault();\n setMouseState({ type: 'none' });\n\n // reset viewport if start === end, i.e. a click without movement\n if (viewport.startTimeUnixMs === viewport.endTimeUnixMs) {\n setViewport({ startTimeUnixMs: trace.startTimeUnixMs, endTimeUnixMs: trace.endTimeUnixMs });\n }\n });\n\n // capture mouseMove and mouseUp outside the element by attaching them to the window object\n useEffect(() => {\n function startMouseAction(): void {\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('mouseup', handleMouseUp);\n document.body.style.cursor = mouseState.type === 'resize' ? 'col-resize' : 'move';\n }\n\n function stopMouseAction(): void {\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('mouseup', handleMouseUp);\n document.body.style.cursor = 'inherit';\n }\n\n if (mouseState.type === 'none') {\n stopMouseAction();\n } else {\n startMouseAction();\n }\n\n return stopMouseAction;\n }, [mouseState, handleMouseMove, handleMouseUp]);\n\n return (\n <Box ref={wrapperRef} sx={{ position: 'relative', height }} onMouseDown={handleMouseDown}>\n <canvas ref={canvasRef} width={width} height={height} style={{ position: 'absolute' }} />\n <Ticks />\n <CutoffBox data-elem=\"cutoffBox\" style={{ left: 0, width: `${relativeCutoffLeft * 100}%` }} />\n <Resizer data-elem=\"resizerLeft\" style={{ left: `${relativeCutoffLeft * 100}%` }} />\n <Resizer data-elem=\"resizerRight\" style={{ right: `${relativeCutoffRight * 100}%` }} />\n <CutoffBox data-elem=\"cutoffBox\" style={{ right: 0, width: `${relativeCutoffRight * 100}%` }} />\n </Box>\n );\n}\n\nconst CutoffBox = styled(Box)({\n position: 'absolute',\n height: '100%',\n backgroundColor: 'rgba(225, 225, 225, .5)',\n});\n\nconst Resizer = styled(Box)(({ theme }) => ({\n position: 'absolute',\n height: '100%',\n backgroundColor: theme.palette.divider,\n width: '2px',\n cursor: 'col-resize',\n\n // increase clickable area from 2px to 8px\n '&:before': {\n position: 'absolute',\n width: '8px',\n left: '-3px',\n top: 0,\n bottom: 0,\n content: '\" \"',\n zIndex: 1, // without zIndex, the cutoff boxes partially hide this element\n },\n}));\n"],"names":["Box","styled","useTheme","useChartsTheme","useEvent","useEffect","useRef","useState","useCallback","useResizeObserver","Ticks","getSpanColor","drawSpans","CANVAS_HEIGHT","Canvas","props","options","trace","viewport","setViewport","muiTheme","chartsTheme","width","ref","wrapperRef","height","canvasRef","mouseState","setMouseState","type","traceDuration","endTimeUnixMs","startTimeUnixMs","relativeCutoffLeft","relativeCutoffRight","spanColorGenerator","span","visual","palette","mode","current","ctx","getContext","translateCursorToTime","e","offsetX","clientX","getBoundingClientRect","left","handleMouseDown","preventDefault","target","HTMLElement","isDefaultViewport","elem","dataset","cursor","fixedPoint","start","end","handleMouseMove","pointA","pointB","Math","max","min","handleMouseUp","startMouseAction","window","addEventListener","document","body","style","stopMouseAction","removeEventListener","sx","position","onMouseDown","canvas","CutoffBox","data-elem","Resizer","right","backgroundColor","theme","divider","top","bottom","content","zIndex"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,gBAAgB;AACtD,SAASC,cAAc,QAAQ,yBAAyB;AACxD,SAASC,QAAQ,QAAQ,4BAA4B;AAErD,SAASC,SAAS,EAAEC,MAAM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":3,"sources":["../../../../src/TracingGanttChart/MiniGanttChart/Canvas.tsx"],"sourcesContent":["// Copyright 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 { Box, styled, useTheme } from '@mui/material';\nimport { useChartsTheme } from '@perses-dev/components';\nimport { useEvent } from '@perses-dev/plugin-system';\nimport type { MouseEvent as ReactMouseEvent, ReactElement } from 'react';\nimport { useEffect, useRef, useState, useCallback } from 'react';\nimport useResizeObserver from 'use-resize-observer';\n\nimport type { TracingGanttChartOptions } from '../../gantt-chart-model';\nimport { Ticks } from '../Ticks';\nimport type { Span, Trace } from '../trace';\nimport type { Viewport } from '../utils';\nimport { getSpanColor } from '../utils';\nimport { drawSpans } from './draw';\n\nconst CANVAS_HEIGHT = 60;\n\ninterface CanvasProps {\n options: TracingGanttChartOptions;\n trace: Trace;\n viewport: Viewport;\n setViewport: (v: Viewport) => void;\n}\n\ntype MouseState =\n | { type: 'none' }\n | { type: 'resize'; fixedPoint: number }\n | { type: 'drag'; start: number; end: number };\n\nexport function Canvas(props: CanvasProps): ReactElement {\n const { options, trace, viewport, setViewport } = props;\n const muiTheme = useTheme();\n const chartsTheme = useChartsTheme();\n // the <canvas> element must have an absolute width and height to avoid rendering problems\n // the wrapper box is required to get the available dimensions for the <canvas> element\n const { width, ref: wrapperRef } = useResizeObserver();\n const height = CANVAS_HEIGHT;\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const [mouseState, setMouseState] = useState<MouseState>({ type: 'none' });\n\n const traceDuration = trace.endTimeUnixMs - trace.startTimeUnixMs;\n const relativeCutoffLeft = (viewport.startTimeUnixMs - trace.startTimeUnixMs) / traceDuration;\n const relativeCutoffRight = (trace.endTimeUnixMs - viewport.endTimeUnixMs) / traceDuration;\n\n const spanColorGenerator = useCallback(\n (span: Span) => getSpanColor(muiTheme, chartsTheme, options.visual?.palette?.mode, span),\n [muiTheme, chartsTheme, options.visual?.palette?.mode],\n );\n\n useEffect(() => {\n if (!canvasRef.current || !width) return;\n\n const ctx = canvasRef.current.getContext('2d');\n if (!ctx) return;\n\n drawSpans(ctx, width, CANVAS_HEIGHT, trace, spanColorGenerator);\n }, [width, trace, spanColorGenerator]);\n\n const translateCursorToTime = (e: ReactMouseEvent | MouseEvent): number => {\n if (!canvasRef.current || !width) return 0;\n // e.nativeEvent.offsetX doesn't work when sliding over a tick box\n const offsetX = e.clientX - canvasRef.current.getBoundingClientRect().left;\n return trace.startTimeUnixMs + (offsetX / width) * traceDuration;\n };\n\n const handleMouseDown = (e: ReactMouseEvent<HTMLDivElement>): void => {\n e.preventDefault();\n if (!(e.target instanceof HTMLElement)) return;\n\n const isDefaultViewport =\n viewport.startTimeUnixMs === trace.startTimeUnixMs && viewport.endTimeUnixMs === trace.endTimeUnixMs;\n const elem = e.target.dataset['elem'];\n const cursor = translateCursorToTime(e);\n\n if (elem === 'resizerLeft') {\n setMouseState({ type: 'resize', fixedPoint: viewport.endTimeUnixMs });\n } else if (elem === 'resizerRight') {\n setMouseState({ type: 'resize', fixedPoint: viewport.startTimeUnixMs });\n } else if (elem === 'cutoffBox' || isDefaultViewport) {\n setMouseState({ type: 'resize', fixedPoint: cursor });\n setViewport({ startTimeUnixMs: cursor, endTimeUnixMs: cursor });\n } else {\n setMouseState({\n type: 'drag',\n start: cursor - viewport.startTimeUnixMs,\n end: viewport.endTimeUnixMs - cursor,\n });\n }\n };\n\n // need stable reference for window.removeEventListener() in useEffect() below\n const handleMouseMove = useEvent((e: MouseEvent) => {\n e.preventDefault();\n\n switch (mouseState.type) {\n case 'none':\n return;\n\n case 'resize': {\n const pointA = mouseState.fixedPoint;\n const pointB = translateCursorToTime(e);\n\n let start, end;\n if (pointA < pointB) {\n start = pointA;\n end = pointB;\n } else {\n start = pointB;\n end = pointA;\n }\n\n setViewport({\n startTimeUnixMs: Math.max(start, trace.startTimeUnixMs),\n endTimeUnixMs: Math.min(end, trace.endTimeUnixMs),\n });\n return;\n }\n\n case 'drag': {\n // avoid using e.movementX here, as it skips events in chrome,\n // resulting in the mouse pointer moving faster than the viewport box\n const { start, end } = mouseState;\n let cursor = translateCursorToTime(e);\n\n if (cursor - start < trace.startTimeUnixMs) {\n cursor = trace.startTimeUnixMs + start;\n }\n if (cursor + end > trace.endTimeUnixMs) {\n cursor = trace.endTimeUnixMs - end;\n }\n\n setViewport({\n startTimeUnixMs: cursor - start,\n endTimeUnixMs: cursor + end,\n });\n return;\n }\n }\n });\n\n // need stable reference for window.removeEventListener() in useEffect() below\n const handleMouseUp = useEvent((e: MouseEvent) => {\n e.preventDefault();\n setMouseState({ type: 'none' });\n\n // reset viewport if start === end, i.e. a click without movement\n if (viewport.startTimeUnixMs === viewport.endTimeUnixMs) {\n setViewport({ startTimeUnixMs: trace.startTimeUnixMs, endTimeUnixMs: trace.endTimeUnixMs });\n }\n });\n\n // capture mouseMove and mouseUp outside the element by attaching them to the window object\n useEffect(() => {\n function startMouseAction(): void {\n window.addEventListener('mousemove', handleMouseMove);\n window.addEventListener('mouseup', handleMouseUp);\n document.body.style.cursor = mouseState.type === 'resize' ? 'col-resize' : 'move';\n }\n\n function stopMouseAction(): void {\n window.removeEventListener('mousemove', handleMouseMove);\n window.removeEventListener('mouseup', handleMouseUp);\n document.body.style.cursor = 'inherit';\n }\n\n if (mouseState.type === 'none') {\n stopMouseAction();\n } else {\n startMouseAction();\n }\n\n return stopMouseAction;\n }, [mouseState, handleMouseMove, handleMouseUp]);\n\n return (\n <Box ref={wrapperRef} sx={{ position: 'relative', height }} onMouseDown={handleMouseDown}>\n <canvas ref={canvasRef} width={width} height={height} style={{ position: 'absolute' }} />\n <Ticks />\n <CutoffBox data-elem=\"cutoffBox\" style={{ left: 0, width: `${relativeCutoffLeft * 100}%` }} />\n <Resizer data-elem=\"resizerLeft\" style={{ left: `${relativeCutoffLeft * 100}%` }} />\n <Resizer data-elem=\"resizerRight\" style={{ right: `${relativeCutoffRight * 100}%` }} />\n <CutoffBox data-elem=\"cutoffBox\" style={{ right: 0, width: `${relativeCutoffRight * 100}%` }} />\n </Box>\n );\n}\n\nconst CutoffBox = styled(Box)({\n position: 'absolute',\n height: '100%',\n backgroundColor: 'rgba(225, 225, 225, .5)',\n});\n\nconst Resizer = styled(Box)(({ theme }) => ({\n position: 'absolute',\n height: '100%',\n backgroundColor: theme.palette.divider,\n width: '2px',\n cursor: 'col-resize',\n\n // increase clickable area from 2px to 8px\n '&:before': {\n position: 'absolute',\n width: '8px',\n left: '-3px',\n top: 0,\n bottom: 0,\n content: '\" \"',\n zIndex: 1, // without zIndex, the cutoff boxes partially hide this element\n },\n}));\n"],"names":["Box","styled","useTheme","useChartsTheme","useEvent","useEffect","useRef","useState","useCallback","useResizeObserver","Ticks","getSpanColor","drawSpans","CANVAS_HEIGHT","Canvas","props","options","trace","viewport","setViewport","muiTheme","chartsTheme","width","ref","wrapperRef","height","canvasRef","mouseState","setMouseState","type","traceDuration","endTimeUnixMs","startTimeUnixMs","relativeCutoffLeft","relativeCutoffRight","spanColorGenerator","span","visual","palette","mode","current","ctx","getContext","translateCursorToTime","e","offsetX","clientX","getBoundingClientRect","left","handleMouseDown","preventDefault","target","HTMLElement","isDefaultViewport","elem","dataset","cursor","fixedPoint","start","end","handleMouseMove","pointA","pointB","Math","max","min","handleMouseUp","startMouseAction","window","addEventListener","document","body","style","stopMouseAction","removeEventListener","sx","position","onMouseDown","canvas","CutoffBox","data-elem","Resizer","right","backgroundColor","theme","divider","top","bottom","content","zIndex"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE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AAO;QACtC/D,OAAO;QACPkC,QAAQ;QAER,0CAA0C;QAC1C,YAAY;YACVoB,UAAU;YACVtD,OAAO;YACP0B,MAAM;YACNsC,KAAK;YACLC,QAAQ;YACRC,SAAS;YACTC,QAAQ;QACV;IACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TracingGanttChart.d.ts","sourceRoot":"","sources":["../../../src/TracingGanttChart/TracingGanttChart.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,WAAW,MAAM,gEAAgE,CAAC;AACnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAYlF,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,wBAAwB,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"TracingGanttChart.d.ts","sourceRoot":"","sources":["../../../src/TracingGanttChart/TracingGanttChart.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,WAAW,MAAM,gEAAgE,CAAC;AACnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAYlF,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,wBAAwB,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CAgE7E"}
|
|
@@ -50,7 +50,6 @@ import { TraceHeaderBar } from "./TraceHeaderBar.js";
|
|
|
50
50
|
// setTableWidth() is only called by <ResizableDivider />
|
|
51
51
|
const [tableWidth, setTableWidth] = useState(0.82);
|
|
52
52
|
const gap = 2;
|
|
53
|
-
const spacing = ganttChart.current ? parseFloat(getComputedStyle(ganttChart.current).columnGap) || 0 : 0;
|
|
54
53
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
55
54
|
ref: ganttChart,
|
|
56
55
|
direction: "row",
|
|
@@ -94,7 +93,6 @@ import { TraceHeaderBar } from "./TraceHeaderBar.js";
|
|
|
94
93
|
children: [
|
|
95
94
|
/*#__PURE__*/ _jsx(ResizableDivider, {
|
|
96
95
|
parentRef: ganttChart,
|
|
97
|
-
spacing: spacing,
|
|
98
96
|
onMove: setTableWidth
|
|
99
97
|
}),
|
|
100
98
|
/*#__PURE__*/ _jsx(Box, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/TracingGanttChart/TracingGanttChart.tsx"],"sourcesContent":["// Copyright 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 { Box, Stack } from '@mui/material';\nimport type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace';\nimport type { ReactElement } from 'react';\nimport { useMemo, useRef, useState } from 'react';\n\nimport type { CustomLinks, TracingGanttChartOptions } from '../gantt-chart-model';\nimport { DetailPane } from './DetailPane/DetailPane';\nimport { GanttTable } from './GanttTable/GanttTable';\nimport { GanttTableProvider } from './GanttTable/GanttTableProvider';\nimport { ResizableDivider } from './GanttTable/ResizableDivider';\nimport { MiniGanttChart } from './MiniGanttChart/MiniGanttChart';\nimport { useSpanSearch } from './Search';\nimport type { Span } from './trace';\nimport { getTraceModel } from './trace';\nimport { TraceHeaderBar } from './TraceHeaderBar';\nimport type { Viewport } from './utils';\n\nexport interface TracingGanttChartProps {\n options: TracingGanttChartOptions;\n customLinks?: CustomLinks;\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, customLinks, trace: otlpTrace } = props;\n\n const trace = useMemo(() => {\n try {\n return getTraceModel(otlpTrace);\n } catch (e) {\n throw new Error(`Error: unable to parse trace: ${e}`, { cause: 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>(() =>\n options.selectedSpanId ? trace.spanById.get(options.selectedSpanId) : undefined,\n );\n const search = useSpanSearch(trace);\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
|
|
1
|
+
{"version":3,"sources":["../../../src/TracingGanttChart/TracingGanttChart.tsx"],"sourcesContent":["// Copyright 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 { Box, Stack } from '@mui/material';\nimport type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace';\nimport type { ReactElement } from 'react';\nimport { useMemo, useRef, useState } from 'react';\n\nimport type { CustomLinks, TracingGanttChartOptions } from '../gantt-chart-model';\nimport { DetailPane } from './DetailPane/DetailPane';\nimport { GanttTable } from './GanttTable/GanttTable';\nimport { GanttTableProvider } from './GanttTable/GanttTableProvider';\nimport { ResizableDivider } from './GanttTable/ResizableDivider';\nimport { MiniGanttChart } from './MiniGanttChart/MiniGanttChart';\nimport { useSpanSearch } from './Search';\nimport type { Span } from './trace';\nimport { getTraceModel } from './trace';\nimport { TraceHeaderBar } from './TraceHeaderBar';\nimport type { Viewport } from './utils';\n\nexport interface TracingGanttChartProps {\n options: TracingGanttChartOptions;\n customLinks?: CustomLinks;\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, customLinks, trace: otlpTrace } = props;\n\n const trace = useMemo(() => {\n try {\n return getTraceModel(otlpTrace);\n } catch (e) {\n throw new Error(`Error: unable to parse trace: ${e}`, { cause: 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>(() =>\n options.selectedSpanId ? trace.spanById.get(options.selectedSpanId) : undefined,\n );\n const search = useSpanSearch(trace);\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 <TraceHeaderBar trace={trace} search={search} />\n <MiniGanttChart options={options} trace={trace} viewport={viewport} setViewport={setViewport} />\n <GanttTableProvider>\n <GanttTable\n options={options}\n customLinks={customLinks}\n trace={trace}\n viewport={viewport}\n selectedSpan={selectedSpan}\n onSpanClick={setSelectedSpan}\n matchingSpanIds={search.matchingSpanIds}\n focusedSpanId={search.matchingSpanIds[search.focusedMatchIndex]}\n />\n </GanttTableProvider>\n </Stack>\n {selectedSpan && (\n <>\n <ResizableDivider parentRef={ganttChart} onMove={setTableWidth} />\n <Box\n style={{\n width: `${(1 - tableWidth) * 100}%`,\n minWidth: `${(1 - tableWidth) * 100}%`,\n }}\n sx={{ overflow: 'auto' }}\n >\n <DetailPane\n customLinks={customLinks}\n trace={trace}\n span={selectedSpan}\n onCloseBtnClick={() => setSelectedSpan(undefined)}\n />\n </Box>\n </>\n )}\n </Stack>\n );\n}\n"],"names":["Box","Stack","useMemo","useRef","useState","DetailPane","GanttTable","GanttTableProvider","ResizableDivider","MiniGanttChart","useSpanSearch","getTraceModel","TraceHeaderBar","TracingGanttChart","props","options","customLinks","trace","otlpTrace","e","Error","cause","viewport","setViewport","startTimeUnixMs","endTimeUnixMs","selectedSpan","setSelectedSpan","selectedSpanId","spanById","get","undefined","search","ganttChart","tableWidth","setTableWidth","gap","ref","direction","sx","height","minHeight","flexGrow","onSpanClick","matchingSpanIds","focusedSpanId","focusedMatchIndex","parentRef","onMove","style","width","minWidth","overflow","span","onCloseBtnClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,KAAK,QAAQ,gBAAgB;AAG3C,SAASC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAGlD,SAASC,UAAU,QAAQ,6BAA0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AAUC,aAAaA;;kCACjF,KAAChB;kCACC,cAAA,KAACD;4BACCS,SAASA;4BACTC,aAAaA;4BACbC,OAAOA;4BACPK,UAAUA;4BACVI,cAAcA;4BACdiB,aAAahB;4BACbiB,iBAAiBZ,OAAOY,eAAe;4BACvCC,eAAeb,OAAOY,eAAe,CAACZ,OAAOc,iBAAiB,CAAC;;;;;YAIpEpB,8BACC;;kCACE,KAAClB;wBAAiBuC,WAAWd;wBAAYe,QAAQb;;kCACjD,KAACnC;wBACCiD,OAAO;4BACLC,OAAO,GAAG,AAAC,CAAA,IAAIhB,UAAS,IAAK,IAAI,CAAC,CAAC;4BACnCiB,UAAU,GAAG,AAAC,CAAA,IAAIjB,UAAS,IAAK,IAAI,CAAC,CAAC;wBACxC;wBACAK,IAAI;4BAAEa,UAAU;wBAAO;kCAEvB,cAAA,KAAC/C;4BACCW,aAAaA;4BACbC,OAAOA;4BACPoC,MAAM3B;4BACN4B,iBAAiB,IAAM3B,gBAAgBI;;;;;;;AAOrD"}
|
|
@@ -60,6 +60,7 @@ function buildKeyValue(tag) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
function buildAnyValue(tags) {
|
|
63
|
+
const tagType = tags.type;
|
|
63
64
|
switch(tags.type){
|
|
64
65
|
case 'string':
|
|
65
66
|
return {
|
|
@@ -70,8 +71,7 @@ function buildAnyValue(tags) {
|
|
|
70
71
|
intValue: tags.value.toString()
|
|
71
72
|
};
|
|
72
73
|
default:
|
|
73
|
-
|
|
74
|
-
throw new Error(`unknown jaeger tag type ${tags.type}`);
|
|
74
|
+
throw new Error(`unknown jaeger tag type ${tagType}`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/test/convert/jaeger.ts"],"sourcesContent":["// Copyright 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 type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common';\nimport type * as otlpresourcev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/resource/v1/resource';\nimport type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace';\n\n// the following Jaeger data types and parsing function should eventually be moved to a Jaeger data source plugin\n\nexport interface JaegerTrace {\n traceID: string;\n spans: Span[];\n processes: unknown;\n warnings: unknown;\n}\n\ninterface Span {\n traceID: string;\n spanID: string;\n hasChildren: boolean;\n childSpanIds: string[];\n depth: number;\n processID: string;\n process: Process;\n\n operationName: string;\n /** start time in microseconds */\n startTime: number;\n relativeStartTime: number;\n duration: number;\n tags: Tag[];\n references: unknown;\n logs: unknown;\n warnings: unknown;\n}\n\ninterface Process {\n serviceName: string;\n tags: Tag[];\n}\n\ntype Tag =\n | {\n type: 'string';\n key: string;\n value: string;\n }\n | {\n type: 'int64';\n key: string;\n value: number;\n };\n\nexport function jaegerTraceToOTLP(jaegerTrace: JaegerTrace): otlptracev1.TracesData {\n return {\n resourceSpans: jaegerTrace.spans.map(buildResourceSpan),\n };\n}\n\nfunction buildResourceSpan(span: Span): otlptracev1.ResourceSpan {\n return {\n resource: buildResource(span.process),\n scopeSpans: [\n {\n scope: {\n name: '',\n },\n spans: [\n {\n traceId: span.traceID,\n spanId: span.spanID,\n name: span.operationName,\n kind: '',\n startTimeUnixNano: (span.startTime * 1000).toString(),\n endTimeUnixNano: ((span.startTime + span.duration) * 1000).toString(),\n attributes: span.tags.map(buildKeyValue),\n events: [],\n status: {},\n },\n ],\n },\n ],\n };\n}\n\nfunction buildResource(process: Process): otlpresourcev1.Resource {\n return {\n attributes: [\n { key: 'service.name', value: { stringValue: process.serviceName } },\n ...process.tags.map(buildKeyValue),\n ],\n };\n}\n\nfunction buildKeyValue(tag: Tag): otlpcommonv1.KeyValue {\n return { key: tag.key, value: buildAnyValue(tag) };\n}\n\nfunction buildAnyValue(tags: Tag): otlpcommonv1.AnyValue {\n switch (tags.type) {\n case 'string':\n return { stringValue: tags.value };\n case 'int64':\n return { intValue: tags.value.toString() };\n default:\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/test/convert/jaeger.ts"],"sourcesContent":["// Copyright 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 type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common';\nimport type * as otlpresourcev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/resource/v1/resource';\nimport type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace';\n\n// the following Jaeger data types and parsing function should eventually be moved to a Jaeger data source plugin\n\nexport interface JaegerTrace {\n traceID: string;\n spans: Span[];\n processes: unknown;\n warnings: unknown;\n}\n\ninterface Span {\n traceID: string;\n spanID: string;\n hasChildren: boolean;\n childSpanIds: string[];\n depth: number;\n processID: string;\n process: Process;\n\n operationName: string;\n /** start time in microseconds */\n startTime: number;\n relativeStartTime: number;\n duration: number;\n tags: Tag[];\n references: unknown;\n logs: unknown;\n warnings: unknown;\n}\n\ninterface Process {\n serviceName: string;\n tags: Tag[];\n}\n\ntype Tag =\n | {\n type: 'string';\n key: string;\n value: string;\n }\n | {\n type: 'int64';\n key: string;\n value: number;\n };\n\nexport function jaegerTraceToOTLP(jaegerTrace: JaegerTrace): otlptracev1.TracesData {\n return {\n resourceSpans: jaegerTrace.spans.map(buildResourceSpan),\n };\n}\n\nfunction buildResourceSpan(span: Span): otlptracev1.ResourceSpan {\n return {\n resource: buildResource(span.process),\n scopeSpans: [\n {\n scope: {\n name: '',\n },\n spans: [\n {\n traceId: span.traceID,\n spanId: span.spanID,\n name: span.operationName,\n kind: '',\n startTimeUnixNano: (span.startTime * 1000).toString(),\n endTimeUnixNano: ((span.startTime + span.duration) * 1000).toString(),\n attributes: span.tags.map(buildKeyValue),\n events: [],\n status: {},\n },\n ],\n },\n ],\n };\n}\n\nfunction buildResource(process: Process): otlpresourcev1.Resource {\n return {\n attributes: [\n { key: 'service.name', value: { stringValue: process.serviceName } },\n ...process.tags.map(buildKeyValue),\n ],\n };\n}\n\nfunction buildKeyValue(tag: Tag): otlpcommonv1.KeyValue {\n return { key: tag.key, value: buildAnyValue(tag) };\n}\n\nfunction buildAnyValue(tags: Tag): otlpcommonv1.AnyValue {\n const tagType = tags.type;\n switch (tags.type) {\n case 'string':\n return { stringValue: tags.value };\n case 'int64':\n return { intValue: tags.value.toString() };\n default:\n throw new Error(`unknown jaeger tag type ${tagType}`);\n }\n}\n"],"names":["jaegerTraceToOTLP","jaegerTrace","resourceSpans","spans","map","buildResourceSpan","span","resource","buildResource","process","scopeSpans","scope","name","traceId","traceID","spanId","spanID","operationName","kind","startTimeUnixNano","startTime","toString","endTimeUnixNano","duration","attributes","tags","buildKeyValue","events","status","key","value","stringValue","serviceName","tag","buildAnyValue","tagType","type","intValue","Error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAoDjC,OAAO,SAASA,kBAAkBC,WAAwB;IACxD,OAAO;QACLC,eAAeD,YAAYE,KAAK,CAACC,GAAG,CAAC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
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.14.0-
|
|
8
|
+
"buildVersion": "0.14.0-rc.1",
|
|
9
9
|
"buildName": "@perses-dev/tracing-gantt-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/TracingGanttChart.
|
|
12
|
+
"name": "__mf/js/TracingGanttChart.d9b59f93.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"zip": "",
|
|
20
20
|
"api": ""
|
|
21
21
|
},
|
|
22
|
-
"globalName": "
|
|
22
|
+
"globalName": "TracingGanttChart_0_14_0_rc_1",
|
|
23
23
|
"pluginVersion": "2.9.2",
|
|
24
|
-
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/TracingGanttChart~0.14.0-
|
|
24
|
+
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/TracingGanttChart~0.14.0-rc.1/\"; }"
|
|
25
25
|
},
|
|
26
26
|
"shared": [
|
|
27
27
|
{
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"js": {
|
|
35
35
|
"async": [],
|
|
36
36
|
"sync": [
|
|
37
|
-
"__mf/js/async/274.
|
|
37
|
+
"__mf/js/async/274.53fc26a4.js"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"css": {
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"js": {
|
|
55
55
|
"async": [],
|
|
56
56
|
"sync": [
|
|
57
|
-
"__mf/js/async/235.
|
|
58
|
-
"__mf/js/async/616.
|
|
57
|
+
"__mf/js/async/235.0675e691.js",
|
|
58
|
+
"__mf/js/async/616.be150b44.js"
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"css": {
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"js": {
|
|
76
76
|
"async": [],
|
|
77
77
|
"sync": [
|
|
78
|
-
"__mf/js/async/587.
|
|
79
|
-
"__mf/js/async/968.
|
|
78
|
+
"__mf/js/async/587.d494e69b.js",
|
|
79
|
+
"__mf/js/async/968.5dcb60d0.js"
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
82
|
"css": {
|
|
@@ -89,20 +89,20 @@
|
|
|
89
89
|
{
|
|
90
90
|
"id": "TracingGanttChart:@perses-dev/components",
|
|
91
91
|
"name": "@perses-dev/components",
|
|
92
|
-
"version": "0.55.0-
|
|
92
|
+
"version": "0.55.0-rc.1",
|
|
93
93
|
"singleton": true,
|
|
94
|
-
"requiredVersion": "^0.55.0-
|
|
94
|
+
"requiredVersion": "^0.55.0-rc.1",
|
|
95
95
|
"assets": {
|
|
96
96
|
"js": {
|
|
97
97
|
"async": [],
|
|
98
98
|
"sync": [
|
|
99
|
-
"__mf/js/async/
|
|
99
|
+
"__mf/js/async/181.1dd3d537.js"
|
|
100
100
|
]
|
|
101
101
|
},
|
|
102
102
|
"css": {
|
|
103
103
|
"async": [],
|
|
104
104
|
"sync": [
|
|
105
|
-
"__mf/css/async/
|
|
105
|
+
"__mf/css/async/181.85c2cbf6.css"
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
},
|
|
@@ -111,14 +111,14 @@
|
|
|
111
111
|
{
|
|
112
112
|
"id": "TracingGanttChart:@perses-dev/plugin-system",
|
|
113
113
|
"name": "@perses-dev/plugin-system",
|
|
114
|
-
"version": "0.55.0-
|
|
114
|
+
"version": "0.55.0-rc.1",
|
|
115
115
|
"singleton": true,
|
|
116
|
-
"requiredVersion": "^0.55.0-
|
|
116
|
+
"requiredVersion": "^0.55.0-rc.1",
|
|
117
117
|
"assets": {
|
|
118
118
|
"js": {
|
|
119
119
|
"async": [],
|
|
120
120
|
"sync": [
|
|
121
|
-
"__mf/js/async/
|
|
121
|
+
"__mf/js/async/255.9c3cabe2.js"
|
|
122
122
|
]
|
|
123
123
|
},
|
|
124
124
|
"css": {
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"js": {
|
|
139
139
|
"async": [],
|
|
140
140
|
"sync": [
|
|
141
|
-
"__mf/js/async/192.
|
|
141
|
+
"__mf/js/async/192.f15300f5.js"
|
|
142
142
|
]
|
|
143
143
|
},
|
|
144
144
|
"css": {
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"js": {
|
|
159
159
|
"async": [],
|
|
160
160
|
"sync": [
|
|
161
|
-
"__mf/js/async/873.
|
|
161
|
+
"__mf/js/async/873.85d15782.js"
|
|
162
162
|
]
|
|
163
163
|
},
|
|
164
164
|
"css": {
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"js": {
|
|
179
179
|
"async": [],
|
|
180
180
|
"sync": [
|
|
181
|
-
"__mf/js/async/392.
|
|
181
|
+
"__mf/js/async/392.0c76141a.js"
|
|
182
182
|
]
|
|
183
183
|
},
|
|
184
184
|
"css": {
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
"js": {
|
|
199
199
|
"async": [],
|
|
200
200
|
"sync": [
|
|
201
|
-
"__mf/js/async/470.
|
|
201
|
+
"__mf/js/async/470.c580b0f9.js"
|
|
202
202
|
]
|
|
203
203
|
},
|
|
204
204
|
"css": {
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
"js": {
|
|
219
219
|
"async": [],
|
|
220
220
|
"sync": [
|
|
221
|
-
"__mf/js/async/121.
|
|
221
|
+
"__mf/js/async/121.92df80eb.js"
|
|
222
222
|
]
|
|
223
223
|
},
|
|
224
224
|
"css": {
|
|
@@ -238,7 +238,7 @@
|
|
|
238
238
|
"js": {
|
|
239
239
|
"async": [],
|
|
240
240
|
"sync": [
|
|
241
|
-
"__mf/js/async/978.
|
|
241
|
+
"__mf/js/async/978.913d8c4f.js"
|
|
242
242
|
]
|
|
243
243
|
},
|
|
244
244
|
"css": {
|
|
@@ -257,26 +257,26 @@
|
|
|
257
257
|
"assets": {
|
|
258
258
|
"js": {
|
|
259
259
|
"sync": [
|
|
260
|
-
"__mf/js/async/436.
|
|
261
|
-
"__mf/js/async/247.
|
|
262
|
-
"__mf/js/async/672.
|
|
263
|
-
"__mf/js/async/__federation_expose_TracingGanttChart.
|
|
260
|
+
"__mf/js/async/436.ab3ccc6d.js",
|
|
261
|
+
"__mf/js/async/247.24f55530.js",
|
|
262
|
+
"__mf/js/async/672.f46ddfc3.js",
|
|
263
|
+
"__mf/js/async/__federation_expose_TracingGanttChart.d3bb9efc.js"
|
|
264
264
|
],
|
|
265
265
|
"async": [
|
|
266
|
-
"__mf/js/async/588.
|
|
267
|
-
"__mf/js/async/71.
|
|
268
|
-
"__mf/js/async/43.
|
|
269
|
-
"__mf/js/async/209.
|
|
270
|
-
"__mf/js/async/lib-router.
|
|
271
|
-
"__mf/js/async/356.
|
|
272
|
-
"__mf/js/async/77.
|
|
273
|
-
"__mf/js/async/496.
|
|
266
|
+
"__mf/js/async/588.957ec837.js",
|
|
267
|
+
"__mf/js/async/71.a381e77a.js",
|
|
268
|
+
"__mf/js/async/43.4c3c5c0f.js",
|
|
269
|
+
"__mf/js/async/209.fd27698d.js",
|
|
270
|
+
"__mf/js/async/lib-router.c5a9412b.js",
|
|
271
|
+
"__mf/js/async/356.a870fa96.js",
|
|
272
|
+
"__mf/js/async/77.c9254c23.js",
|
|
273
|
+
"__mf/js/async/496.fce0470b.js"
|
|
274
274
|
]
|
|
275
275
|
},
|
|
276
276
|
"css": {
|
|
277
277
|
"sync": [],
|
|
278
278
|
"async": [
|
|
279
|
-
"__mf/css/async/
|
|
279
|
+
"__mf/css/async/181.85c2cbf6.css"
|
|
280
280
|
]
|
|
281
281
|
}
|
|
282
282
|
},
|