Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTML Report Stats Table #2817

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,10 @@ def to_dict(self, escape_string_values=False):
"max_response_time": proper_round(self.max_response_time),
"current_rps": self.current_rps,
"current_fail_per_sec": self.current_fail_per_sec,
"avg_response_time": self.avg_response_time,
"median_response_time": self.median_response_time,
"total_rps": self.total_rps,
"total_fail_per_sec": self.total_fail_per_sec,
**response_time_percentiles,
"avg_content_length": self.avg_content_length,
}
Expand Down
10 changes: 8 additions & 2 deletions locust/webui/src/components/StatsTable/StatsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ViewColumnSelector from 'components/ViewColumnSelector/ViewColumnSelector
import { swarmTemplateArgs } from 'constants/swarm';
import useSelectViewColumns from 'hooks/useSelectViewColumns';
import { IRootState } from 'redux/store';
import { ITableStructure } from 'types/table.types';
import { ISwarmStat } from 'types/ui.types';

const percentilesToStatisticsRows = swarmTemplateArgs.percentilesToStatistics
Expand All @@ -14,7 +15,7 @@ const percentilesToStatisticsRows = swarmTemplateArgs.percentilesToStatistics
}))
: [];

const tableStructure = [
export const baseTableStructure = [
{ key: 'method', title: 'Type' },
{ key: 'name', title: 'Name' },
{ key: 'numRequests', title: '# Requests' },
Expand All @@ -29,7 +30,12 @@ const tableStructure = [
{ key: 'currentFailPerSec', title: 'Current Failures/s', round: 2 },
];

export function StatsTable({ stats }: { stats: ISwarmStat[] }) {
interface IStatsTable {
stats: ISwarmStat[];
tableStructure?: ITableStructure[];
}

export function StatsTable({ stats, tableStructure = baseTableStructure }: IStatsTable) {
const { selectedColumns, addColumn, removeColumn, filteredStructure } =
useSelectViewColumns(tableStructure);

Expand Down
15 changes: 14 additions & 1 deletion locust/webui/src/pages/HtmlReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ import { formatLocaleString } from 'utils/date';

const theme = createTheme(window.theme || INITIAL_THEME);

const statsReportTableStructure = [
{ key: 'method', title: 'Type' },
{ key: 'name', title: 'Name' },
{ key: 'numRequests', title: '# Requests' },
{ key: 'numFailures', title: '# Fails' },
{ key: 'avgResponseTime', title: 'Average (ms)', round: 2 },
{ key: 'minResponseTime', title: 'Min (ms)' },
{ key: 'maxResponseTime', title: 'Max (ms)' },
{ key: 'avgContentLength', title: 'Average size (bytes)', round: 2 },
{ key: 'totalRps', title: 'RPS', round: 2 },
{ key: 'totalFailPerSec', title: 'Failures/s', round: 2 },
];

export default function HtmlReport({
locustfile,
showDownloadLink,
Expand Down Expand Up @@ -72,7 +85,7 @@ export default function HtmlReport({
<Typography component='h2' mb={1} noWrap variant='h4'>
Request Statistics
</Typography>
<StatsTable stats={requestsStatistics} />
<StatsTable stats={requestsStatistics} tableStructure={statsReportTableStructure} />
</Box>
{!!responseTimeStatistics.length && (
<Box>
Expand Down
Loading