Skip to content

Commit

Permalink
feature: Tracetest Analyzer Improvements (#2628)
Browse files Browse the repository at this point in the history
* feature: Tracetest Analyzer Improvements

* feature: Tracetest Analyzer Improvements

* fix plugin names

---------

Co-authored-by: Jorge Padilla <[email protected]>
  • Loading branch information
xoscar and jorgeepc authored Jun 1, 2023
1 parent 163fe30 commit 284d2bf
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 66 deletions.
2 changes: 1 addition & 1 deletion server/linter/plugins/common/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
func NewCommonPlugin() model.Plugin {
return CommonPlugin{
BasePlugin: model.BasePlugin{
Name: "Common Issues",
Name: "Common problems",
Description: "Helps you find common problems with your application",
Rules: []model.Rule{
rules.NewEnforceDnsUsageRule(),
Expand Down
2 changes: 1 addition & 1 deletion server/linter/plugins/standards/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
func NewStandardsPlugin() model.Plugin {
return StandardsPlugin{
BasePlugin: model.BasePlugin{
Name: "Global Standards",
Name: "OTel Semantic Conventions",
Description: "Enforce standards for spans and attributes",
Rules: []model.Rule{
rules.NewEnsureSpanNamingRule(),
Expand Down
2 changes: 1 addition & 1 deletion server/linter/resource/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Repository struct {

var defaultlinter = Linter{
ID: id.ID("current"),
Name: "linter",
Name: "analyzer",
Enabled: true,
MinimumScore: 0,
Plugins: []LinterPlugin{
Expand Down
4 changes: 2 additions & 2 deletions server/linter/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package linter_resource
import "github.com/kubeshop/tracetest/server/resourcemanager"

const (
ResourceName = "Linter"
ResourceNamePlural = "Linters"
ResourceName = "Analyzer"
ResourceNamePlural = "Analyzers"
)

var Operations = []resourcemanager.Operation{
Expand Down
14 changes: 9 additions & 5 deletions web/src/components/BetaBadge/BetaBadge.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import {Tag} from 'antd';
import styled from 'styled-components';

export const Badge = styled(Tag).attrs(({theme}) => ({
color: theme.color.primary,
color: theme.color.borderLight,
}))`
font-size: 10px;
margin-left: 5px;
padding: 0 2px;
margin-right: 0;
font-size: ${({theme}) => theme.size.md};
margin: 0;
margin-left: 8px;
padding: 0 8px;
line-height: 15px;
border-radius: 8px;
font-weight: 400;
background: ${({theme}) => theme.color.textSecondary};
color: ${({theme}) => theme.color.primary};
`;
2 changes: 1 addition & 1 deletion web/src/components/BetaBadge/BetaBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as S from './BetaBadge.styled';

const BetaBadge = () => <S.Badge>beta</S.Badge>;
const BetaBadge = () => <S.Badge>Beta</S.Badge>;

export default BetaBadge;
14 changes: 7 additions & 7 deletions web/src/components/RunDetailTrace/LintResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ const LintResults = ({linterResult, trace}: IProps) => {
return (
<S.Container>
<S.Title level={2}>
Linter Results <BetaBadge />
Analyzer Results <BetaBadge />
</S.Title>
<S.Description>
The Tracetest Linter its a plugin based framework used to analyze Open Telemetry traces to help teams improve
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 linter for all tests, go to the <Link to="/settings">settings page</Link>. We have released this initial
version to get feedback from the community. Have thoughts about how to improve the Tracetest Linter? Add to this
<a href={OCTOLIINT_ISSUE_URL}>Issue</a> or <a href={DISCORD_URL}>Discord</a>!
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 linter evaluation as part of the testing capabilities.">
<Tooltip title="Tracetest core system supports analyzer evaluation as part of the testing capabilities.">
<S.ScoreContainer>
<S.Subtitle level={3}>Trace Lint Result</S.Subtitle>{' '}
<S.Subtitle level={3}>Trace Analyzer Result</S.Subtitle>{' '}
<LintScore score={linterResult.score} passed={linterResult.passed} />
</S.ScoreContainer>
</Tooltip>
Expand Down
9 changes: 4 additions & 5 deletions web/src/components/Settings/Linter/Linter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ const Linter = () => (
<S.Container>
<S.Description>
<p>
This beta release of the Tracetest Linter its a plugin based framework used to analyze Open Telemetry traces to
This beta release of the Tracetest Analyzer its a plugin based framework used to audit OpenTelemetry traces to
help teams improve their instrumentation data, find potential problems and provide tips to fix the problems. We
have released this initial version to get feedback from the community. Have thoughts about how to improve the
Tracetest Linter? Add to this
<a href={OCTOLIINT_ISSUE_URL}>Issue</a> or <a href={DISCORD_URL}>Discord</a>! Currently, the linter supports the
following plugins:
Tracetest Analyzer? Add to this <a href={OCTOLIINT_ISSUE_URL}>Issue</a> or <a href={DISCORD_URL}>Discord</a>!
Currently, the analyzer supports the following plugins:
</p>
<S.LinterPluginList>
<li>
<b>Open Telemetry Semantic Conventions.</b> Enforce standards for spans and attributes
<b>OpenTelemetry Semantic Conventions.</b> Enforce standards for spans and attributes
</li>
<li>
<b>Security.</b> Enforce security for spans and attributes
Expand Down
11 changes: 8 additions & 3 deletions web/src/components/Settings/Linter/LinterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ const LinterForm = () => {
}, [form, linter]);

const handleOnSubmit = (values: TDraftLinter) => {
values.minimumScore = parseInt(String(values?.minimumScore ?? 0), 10);
onSubmit([SettingService.getDraftResource(ResourceType.LinterType, values)]);
onSubmit([
SettingService.getDraftResource(ResourceType.AnalyzerType, {
...values,
minimumScore: parseInt(String(values?.minimumScore ?? 0), 10),
plugins: linter.plugins,
}),
]);
};

return (
Expand All @@ -40,7 +45,7 @@ const LinterForm = () => {
<Form.Item name="enabled" valuePropName="checked">
<Switch />
</Form.Item>
<label htmlFor={`${FORM_ID}_enabled`}>Enable Linter for All Tests</label>
<label htmlFor={`${FORM_ID}_enabled`}>Enable Analyzer for All Tests</label>
</S.SwitchContainer>

<Form.Item
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/SpanDetail/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Header = ({span, assertions = {}}: IProps) => {
<Space>
<SSpanNode.BadgeType $hasMargin count={SemanticGroupNamesToText[type]} $type={type} />
{!!lintErrors.length && (
<Tooltip title="This span has lint errors">
<Tooltip title="The analyzer found errors in this span">
<S.LintErrorIcon />
</Tooltip>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const SpanNode = ({data, id, selected}: IProps) => {
<S.LintCloseIcon onClick={() => setIsOpenLintErrors(false)} />
<Space>
<S.LintErrorIcon />
<S.LintTitle level={4}>Lint errors</S.LintTitle>
<S.LintTitle level={4}>Analyzer errors</S.LintTitle>
</Space>
<S.LintBody>
{lintErrors.map(lintError => (
Expand Down
79 changes: 45 additions & 34 deletions web/src/pages/Settings/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Tabs} from 'antd';
import {useSearchParams} from 'react-router-dom';
import Analytics from 'components/Settings/Analytics';
import DataStore from 'components/Settings/DataStore';
import Demo from 'components/Settings/Demo';
Expand All @@ -12,43 +13,53 @@ const TabsKeys = {
DataStore: 'dataStore',
Demo: 'demo',
Polling: 'polling',
Linter: 'linter',
Analyzer: 'analyzer',
};

const Content = () => (
<S.Container>
<S.Header>
<S.Title>Settings</S.Title>
</S.Header>
const Content = () => {
const [query, setQuery] = useSearchParams();

<S.TabsContainer>
<Tabs size="small">
<Tabs.TabPane key={TabsKeys.DataStore} tab="Configure Data Store">
<DataStore />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Analytics} tab="Analytics">
<Analytics />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Polling} tab="Trace Polling">
<Polling />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Demo} tab="Demo">
<Demo />
</Tabs.TabPane>
<Tabs.TabPane
key={TabsKeys.Linter}
tab={
<S.TabTextContainer>
Linter
<BetaBadge />
</S.TabTextContainer>
}
return (
<S.Container>
<S.Header>
<S.Title>Settings</S.Title>
</S.Header>

<S.TabsContainer>
<Tabs
size="small"
defaultActiveKey={query.get('tab') || TabsKeys.DataStore}
onChange={newTab => {
setQuery([['tab', newTab]]);
}}
>
<Linter />
</Tabs.TabPane>
</Tabs>
</S.TabsContainer>
</S.Container>
);
<Tabs.TabPane key={TabsKeys.DataStore} tab="Configure Data Store">
<DataStore />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Analytics} tab="Analytics">
<Analytics />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Polling} tab="Trace Polling">
<Polling />
</Tabs.TabPane>
<Tabs.TabPane key={TabsKeys.Demo} tab="Demo">
<Demo />
</Tabs.TabPane>
<Tabs.TabPane
key={TabsKeys.Analyzer}
tab={
<S.TabTextContainer>
Analyzer
<BetaBadge />
</S.TabTextContainer>
}
>
<Linter />
</Tabs.TabPane>
</Tabs>
</S.TabsContainer>
</S.Container>
);
};

export default Content;
4 changes: 2 additions & 2 deletions web/src/redux/apis/endpoints/Setting.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ const ConfigEndpoint = (builder: TTestApiEndpointBuilder) => ({
}),
getLinter: builder.query<Linter, unknown>({
query: () => ({
url: '/linters/current',
url: '/analyzers/current',
method: HTTP_METHOD.GET,
headers: {'content-type': 'application/json'},
}),
providesTags: () => [{type: TracetestApiTags.SETTING, id: ResourceType.LinterType}],
providesTags: () => [{type: TracetestApiTags.SETTING, id: ResourceType.AnalyzerType}],
transformResponse: (rawLinter: TRawLinter) => Linter(rawLinter),
}),
createSetting: builder.mutation<undefined, {resource: TDraftResource}>({
Expand Down
4 changes: 2 additions & 2 deletions web/src/types/Settings.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ export enum ResourceType {
ConfigType = 'Config',
PollingProfileType = 'PollingProfile',
DemoType = 'Demo',
LinterType = 'Linter',
AnalyzerType = 'Analyzer',
}

export enum ResourceTypePlural {
ConfigType = 'Configs',
PollingProfileType = 'PollingProfiles',
DemoType = 'Demos',
LinterType = 'linters',
AnalyzerType = 'Analyzers',
}

export type TDraftDemo = Record<Required<Demo['type']>, Partial<Demo>>;
Expand Down

0 comments on commit 284d2bf

Please sign in to comment.