-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chore-performance-improvements' of github.com:kubeshop/…
…tracetest into chore-performance-improvements
- Loading branch information
Showing
23 changed files
with
247 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const SpinnerContainer = styled.div` | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
import {SpinnerContainer} from './LoadingSpinner.styled'; | ||
|
||
export {SpinnerContainer}; | ||
|
||
// eslint-disable-next-line no-restricted-exports | ||
export {default} from './LoadingSpinner'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {useCallback, useEffect} from 'react'; | ||
import {Node, NodeChange} from 'react-flow-renderer'; | ||
|
||
import DAG from 'components/Visualization/components/DAG'; | ||
import {useSpan} from 'providers/Span/Span.provider'; | ||
import {useAppDispatch, useAppSelector} from 'redux/hooks'; | ||
import {initNodes, onNodesChange as onNodesChangeAction} from 'redux/slices/DAG.slice'; | ||
import DAGSelectors from 'selectors/DAG.selectors'; | ||
import TraceDiagramAnalyticsService from 'services/Analytics/TraceDiagramAnalytics.service'; | ||
import Trace from 'models/Trace.model'; | ||
import {useTestSpecForm} from '../TestSpecForm/TestSpecForm.provider'; | ||
import LoadingSpinner, {SpinnerContainer} from '../LoadingSpinner'; | ||
|
||
export interface IProps { | ||
trace: Trace; | ||
onNavigateToSpan(spanId: string): void; | ||
} | ||
|
||
const TestDAG = ({trace: {spans}, onNavigateToSpan}: IProps) => { | ||
const dispatch = useAppDispatch(); | ||
const edges = useAppSelector(DAGSelectors.selectEdges); | ||
const nodes = useAppSelector(DAGSelectors.selectNodes); | ||
const {onSelectSpan, matchedSpans, focusedSpan} = useSpan(); | ||
const {isOpen} = useTestSpecForm(); | ||
|
||
useEffect(() => { | ||
dispatch(initNodes({spans})); | ||
}, [dispatch, spans]); | ||
|
||
const onNodesChange = useCallback((changes: NodeChange[]) => dispatch(onNodesChangeAction({changes})), [dispatch]); | ||
|
||
const onNodeClick = useCallback( | ||
(event, {id}: Node) => { | ||
TraceDiagramAnalyticsService.onClickSpan(id); | ||
onSelectSpan(id); | ||
}, | ||
[onSelectSpan] | ||
); | ||
|
||
if (spans.length && !nodes.length) { | ||
return ( | ||
<SpinnerContainer> | ||
<LoadingSpinner /> | ||
</SpinnerContainer> | ||
); | ||
} | ||
|
||
return ( | ||
<DAG | ||
edges={edges} | ||
isMatchedMode={matchedSpans.length > 0 || isOpen} | ||
matchedSpans={matchedSpans} | ||
nodes={nodes} | ||
onNavigateToSpan={onNavigateToSpan} | ||
onNodesChange={onNodesChange} | ||
onNodeClick={onNodeClick} | ||
selectedSpan={focusedSpan} | ||
/> | ||
); | ||
}; | ||
|
||
export default TestDAG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {useAppDispatch, useAppSelector} from 'redux/hooks'; | ||
import TraceSelectors from 'selectors/Trace.selectors'; | ||
import {Node, NodeChange} from 'react-flow-renderer'; | ||
import {changeNodes, initNodes, selectSpan} from 'redux/slices/Trace.slice'; | ||
import TraceDiagramAnalyticsService from 'services/Analytics/TraceDiagramAnalytics.service'; | ||
import {useCallback, useEffect} from 'react'; | ||
import Trace from 'models/Trace.model'; | ||
import DAG from '../Visualization/components/DAG'; | ||
import LoadingSpinner, {SpinnerContainer} from '../LoadingSpinner'; | ||
|
||
interface IProps { | ||
trace: Trace; | ||
onNavigateToSpan(spanId: string): void; | ||
} | ||
|
||
const TraceDAG = ({trace: {spans}, onNavigateToSpan}: IProps) => { | ||
const matchedSpans = useAppSelector(TraceSelectors.selectMatchedSpans); | ||
const selectedSpan = useAppSelector(TraceSelectors.selectSelectedSpan); | ||
const nodes = useAppSelector(TraceSelectors.selectNodes); | ||
const edges = useAppSelector(TraceSelectors.selectEdges); | ||
const isMatchedMode = Boolean(matchedSpans.length); | ||
const dispatch = useAppDispatch(); | ||
|
||
// TODO: Trace will never change, we can calculate this once and then keep using it | ||
useEffect(() => { | ||
dispatch(initNodes({spans})); | ||
}, [dispatch, spans]); | ||
|
||
const onNodesChange = useCallback((changes: NodeChange[]) => dispatch(changeNodes({changes})), [dispatch]); | ||
|
||
const onNodeClick = useCallback( | ||
(event: React.MouseEvent, {id}: Node) => { | ||
event.stopPropagation(); | ||
TraceDiagramAnalyticsService.onClickSpan(id); | ||
dispatch(selectSpan({spanId: id})); | ||
}, | ||
[dispatch] | ||
); | ||
|
||
if (spans.length && !nodes.length) { | ||
return ( | ||
<SpinnerContainer> | ||
<LoadingSpinner /> | ||
</SpinnerContainer> | ||
); | ||
} | ||
|
||
return ( | ||
<DAG | ||
edges={edges} | ||
isMatchedMode={isMatchedMode} | ||
matchedSpans={matchedSpans} | ||
nodes={nodes} | ||
onNavigateToSpan={onNavigateToSpan} | ||
onNodesChange={onNodesChange} | ||
onNodeClick={onNodeClick} | ||
selectedSpan={selectedSpan} | ||
/> | ||
); | ||
}; | ||
|
||
export default TraceDAG; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.