Skip to content

Commit

Permalink
Monitor Tab - The x-axis timeframe should be according to the selecte…
Browse files Browse the repository at this point in the history
…d timeframe (#886)

* Time frame

Signed-off-by: nofar9792 <nofar.cohen@logz.io>

* Fix shifting graph

Signed-off-by: nofar9792 <nofar.cohen@logz.io>

* Remove comment

Signed-off-by: nofar9792 <nofar.cohen@logz.io>

* Calc domain in ctor

Signed-off-by: nofar9792 <nofar.cohen@logz.io>
  • Loading branch information
nofar9792 committed Feb 22, 2022
1 parent 676a90b commit 7348b1e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
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

0 comments on commit 7348b1e

Please sign in to comment.