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 - The x-axis timeframe should be according to the selected timeframe #886

Merged
merged 6 commits into from
Feb 22, 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 @@ -55,7 +55,7 @@ exports[`<MonitorATMServicesView> ATM snapshot test 1`] = `
" metrics in selected timeframe.

<a
href="/search?end=1487076708000000&limit=20&lookback=1h&maxDuration&minDuration&service=s1&start=1487073108000000"
href="/search?end=1466424490000000&limit=20&lookback=1h&maxDuration&minDuration&service=s1&start=1466420890000000"
target="blank"
>
View all traces
Expand Down Expand Up @@ -174,6 +174,12 @@ exports[`<MonitorATMServicesView> ATM snapshot test 1`] = `
showHorizontalLines={true}
showLegend={true}
width={300}
xDomain={
Array [
1466420890000,
1466424490000,
]
}
/>
</Col>
<Col
Expand Down Expand Up @@ -203,6 +209,12 @@ exports[`<MonitorATMServicesView> ATM snapshot test 1`] = `
}
name="Error rate, %"
width={300}
xDomain={
Array [
1466420890000,
1466424490000,
]
}
yDomain={
Array [
0,
Expand Down Expand Up @@ -239,6 +251,12 @@ exports[`<MonitorATMServicesView> ATM snapshot test 1`] = `
name="Request rate, req/s"
showHorizontalLines={true}
width={300}
xDomain={
Array [
1466420890000,
1466424490000,
]
}
/>
</Col>
</Row>
Expand Down Expand Up @@ -335,7 +353,7 @@ exports[`<MonitorATMServicesView> ATM snapshot test 1`] = `
},
]
}
endTime={1487076708000}
endTime={1466424490000}
error={
Object {
"opsCalls": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ describe('<MonitorATMServicesView>', () => {
const mockFetchServices = jest.fn();
const mockFetchAllServiceMetrics = jest.fn();
const mockFetchAggregatedServiceMetrics = jest.fn();
beforeAll(() => {
Date.now = jest.fn(() => 1466424490000);
});

beforeEach(() => {
wrapper = shallow(
Expand All @@ -54,6 +57,7 @@ describe('<MonitorATMServicesView>', () => {

afterEach(() => {
wrapper = null;

jest.clearAllMocks();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const getLoopbackInterval = (interval: number) => {
// export for tests
export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, StateType> {
graphDivWrapper: React.RefObject<HTMLInputElement>;
graphXDomain: number[];
serviceSelectorValue: string = '';
endTime: number = Date.now();
state = {
Expand All @@ -100,6 +101,9 @@ export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, Stat
constructor(props: TProps) {
super(props);
this.graphDivWrapper = React.createRef();

const currentTime = Date.now();
this.graphXDomain = [currentTime - props.selectedTimeFrame, currentTime];
}

componentDidMount() {
Expand Down Expand Up @@ -251,6 +255,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, Stat
showLegend
marginClassName="latency-margins"
showHorizontalLines
xDomain={this.graphXDomain}
/>
</Col>
<Col span={8}>
Expand All @@ -264,6 +269,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, Stat
marginClassName="error-rate-margins"
color="#CD513A"
yDomain={[0, 100]}
xDomain={this.graphXDomain}
/>
</Col>
<Col span={8}>
Expand All @@ -277,6 +283,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent<TProps, Stat
showHorizontalLines
color="#4795BA"
marginClassName="request-margins"
xDomain={this.graphXDomain}
/>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type TProps = {
yDomain?: number[];
color?: string;
marginClassName?: string;
xDomain: number[];
};

type TCrossHairValues = {
Expand Down Expand Up @@ -145,6 +146,7 @@ export class ServiceGraphImpl extends React.PureComponent<TProps> {
marginClassName,
name,
error,
xDomain,
} = this.props;
let GraphComponent = this.generatePlaceholder(<LoadingIndicator centered />);
const noDataComponent = this.generatePlaceholder('No Data');
Expand All @@ -156,6 +158,7 @@ export class ServiceGraphImpl extends React.PureComponent<TProps> {
onMouseLeave={() => this.setState({ crosshairValues: [] })}
width={width}
height={this.height - 74}
xDomain={xDomain}
yDomain={yDomain}
>
{showHorizontalLines ? <HorizontalGridLines /> : null}
Expand Down