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

Monitor Tab - Error rate value should be 0-100 value and not 0-1 #895

Merged
merged 8 commits into from
Feb 28, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ exports[`<MonitorATMServicesView> ATM snapshot test 1`] = `
"metricPoints": Array [
Object {
"x": 1631274747520,
"y": 1,
"y": 100,
},
Object {
"x": 1631274807520,
"y": 1,
"y": 100,
},
],
"quantile": 0.95,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ import OperationTableDetails from './operationDetailsTable';
import LoadingIndicator from '../../common/LoadingIndicator';
import MonitorATMEmptyState from '../EmptyState';
import { ReduxState } from '../../../types';
import { MetricsAPIQueryParams, MetricsReduxState, ServiceOpsMetrics } from '../../../types/metrics';
import {
MetricsAPIQueryParams,
MetricsReduxState,
Points,
ServiceMetricsObject,
ServiceOpsMetrics,
} from '../../../types/metrics';
import prefixUrl from '../../../utils/prefix-url';

import './index.css';
Expand Down Expand Up @@ -86,6 +92,16 @@ export const getLoopbackInterval = (interval: number) => {
return timeFrameObj.label.toLowerCase();
};

const convertServiceErrorRateToPercentages = (serviceErrorRate: null | ServiceMetricsObject) => {
if (!serviceErrorRate) return null;

const wew = serviceErrorRate.metricPoints.map((metricPoint: Points) => {
return { ...metricPoint, y: metricPoint.y! * 100 };
});

return { ...serviceErrorRate, metricPoints: wew };
};

// export for tests
export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, StateType> {
graphDivWrapper: React.RefObject<HTMLInputElement>;
Expand Down Expand Up @@ -175,6 +191,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, Stat

render() {
const { services, metrics, selectedTimeFrame, servicesLoading } = this.props;
const serviceErrorRate = metrics.serviceMetrics ? metrics.serviceMetrics.service_error_rate : null;

if (servicesLoading) {
return <LoadingIndicator vcentered centered />;
Expand Down Expand Up @@ -265,7 +282,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, Stat
loading={metrics.loading}
name="Error rate, %"
width={this.state.graphWidth}
metricsData={metrics.serviceMetrics ? metrics.serviceMetrics.service_error_rate : null}
metricsData={convertServiceErrorRateToPercentages(serviceErrorRate)}
marginClassName="error-rate-margins"
color="#CD513A"
yDomain={[0, 100]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ exports[`<OperationTableDetails> render greater than 0.1 requests value in the t
<div
className="table-graph-avg"
>
1%
100%
</div>
</div>
</td>
Expand Down Expand Up @@ -1647,7 +1647,7 @@ exports[`<OperationTableDetails> render number with more than 2 decimal places v
<div
className="table-graph-avg"
>
1%
100%
</div>
</div>
</td>
Expand Down Expand Up @@ -2337,7 +2337,7 @@ exports[`<OperationTableDetails> render some values in the table 1`] = `
<div
className="table-graph-avg"
>
1%
100%
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class OperationTableDetails extends React.PureComponent<TProps, TState> {
/>
<div className="table-graph-avg">
{typeof value === 'number' && row.dataPoints.service_operation_error_rate.length > 0
? `${value}%`
? `${value * 100}%`
: ''}
</div>
</div>
Expand Down