-
Notifications
You must be signed in to change notification settings - Fork 67
/
LintResults.tsx
141 lines (132 loc) 路 5.48 KB
/
LintResults.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import {CaretUpFilled} from '@ant-design/icons';
import {Link} from 'react-router-dom';
import {Col, Collapse, Row, Space, Tooltip, Typography} from 'antd';
import {useCallback} from 'react';
import LinterResult from 'models/LinterResult.model';
import Span from 'models/Span.model';
import Trace from 'models/Trace.model';
import {useAppDispatch} from 'redux/hooks';
import {selectSpan} from 'redux/slices/Trace.slice';
import {DISCORD_URL, OCTOLIINT_ISSUE_URL} from 'constants/Common.constants';
import * as S from './LintResults.styled';
import LintScore from '../LintScore/LintScore';
import CollapseIcon from './CollapseIcon';
import BetaBadge from '../BetaBadge/BetaBadge';
interface IProps {
linterResult: LinterResult;
trace: Trace;
}
function getSpanName(spans: Span[], traceId: string) {
const span = spans.find(s => s.id === traceId);
return span?.name ?? '';
}
const LintResults = ({linterResult, trace}: IProps) => {
const dispatch = useAppDispatch();
const onSpanResultClick = useCallback(
(spanId: string) => {
dispatch(selectSpan({spanId}));
},
[dispatch]
);
return (
<S.Container>
<S.Title level={2}>
Analyzer Results <BetaBadge />
</S.Title>
<S.Description>
The Tracetest Analyzer its a plugin based framework used to analyze OpenTelemetry traces to help teams improve
their instrumentation data, find potential problems and provide tips to fix the problems. If you want to disable
the analyzer for all tests, go to the <Link to="/settings?tab=analyzer">settings page</Link>. We have released
this initial version to get feedback from the community. Have thoughts about how to improve the Tracetest
Analyzer? Add to this <a href={OCTOLIINT_ISSUE_URL}>Issue</a> or <a href={DISCORD_URL}>Discord</a>!
</S.Description>
<Row gutter={[16, 16]}>
<Col span={8} key="avg_result">
<Tooltip title="Tracetest core system supports analyzer evaluation as part of the testing capabilities.">
<S.ScoreContainer>
<S.Subtitle level={3}>Trace Analyzer Result</S.Subtitle>{' '}
<LintScore score={linterResult.score} passed={linterResult.passed} />
</S.ScoreContainer>
</Tooltip>
</Col>
{linterResult?.plugins?.map(plugin => (
<Col span={8} key={plugin.name}>
<Tooltip title={plugin.description}>
<S.ScoreContainer key={plugin.name}>
<S.Subtitle level={3}>{plugin.name}</S.Subtitle>
<LintScore score={plugin.score} passed={plugin.passed} />
</S.ScoreContainer>
</Tooltip>
</Col>
))}
</Row>
<Collapse expandIcon={({isActive = false}) => <CollapseIcon isCollapsed={isActive} />}>
{linterResult?.plugins?.map(plugin => (
<S.PluginPanel
header={
<Space>
<LintScore width="35px" height="35px" score={plugin.score} passed={plugin.passed} />
<Typography.Text strong>{plugin.name}</Typography.Text>
<Typography.Text type="secondary">{plugin.description}</Typography.Text>
</Space>
}
key={plugin.name}
>
{plugin.rules.map(rule => (
<S.RuleContainer key={rule.name}>
<S.Column>
<S.RuleHeader>
<Space>
{rule.passed ? <S.PassedIcon $small /> : <S.FailedIcon $small />}
<Tooltip title={rule.tips.join(' - ')}>
<Typography.Text strong>{rule.name}</Typography.Text>
</Tooltip>
</Space>
</S.RuleHeader>
<Typography.Text type="secondary" style={{paddingLeft: 20}}>
{rule.description}
</Typography.Text>
</S.Column>
<S.RuleBody>
{rule?.results?.map((result, resultIndex) => (
// eslint-disable-next-line react/no-array-index-key
<div key={`${result.spanId}-${resultIndex}`}>
{result.passed ? (
<S.SpanButton
icon={<CaretUpFilled />}
onClick={() => onSpanResultClick(result.spanId)}
type="link"
>
{getSpanName(trace.spans, result.spanId)}
</S.SpanButton>
) : (
<>
<S.SpanButton
icon={<CaretUpFilled />}
onClick={() => onSpanResultClick(result.spanId)}
type="link"
$error
>
{getSpanName(trace.spans, result.spanId)}
</S.SpanButton>
<div>
{result.errors.map(error => (
<div>
<Typography.Text>{error}</Typography.Text>
</div>
))}
</div>
</>
)}
</div>
))}
</S.RuleBody>
</S.RuleContainer>
))}
</S.PluginPanel>
))}
</Collapse>
</S.Container>
);
};
export default LintResults;