From 7348b1eafc1a75139b8434267876d86026104a8f Mon Sep 17 00:00:00 2001 From: nofar9792 Date: Wed, 23 Feb 2022 01:56:11 +0200 Subject: [PATCH] Monitor Tab - The x-axis timeframe should be according to the selected timeframe (#886) * Time frame Signed-off-by: nofar9792 * Fix shifting graph Signed-off-by: nofar9792 * Remove comment Signed-off-by: nofar9792 * Calc domain in ctor Signed-off-by: nofar9792 --- .../__snapshots__/index.test.js.snap | 22 +++++++++++++++++-- .../Monitor/ServicesView/index.test.js | 4 ++++ .../components/Monitor/ServicesView/index.tsx | 7 ++++++ .../Monitor/ServicesView/serviceGraph.tsx | 3 +++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/__snapshots__/index.test.js.snap b/packages/jaeger-ui/src/components/Monitor/ServicesView/__snapshots__/index.test.js.snap index 0430e24544..93ffb71867 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/__snapshots__/index.test.js.snap +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/__snapshots__/index.test.js.snap @@ -55,7 +55,7 @@ exports[` ATM snapshot test 1`] = ` " metrics in selected timeframe. View all traces @@ -174,6 +174,12 @@ exports[` ATM snapshot test 1`] = ` showHorizontalLines={true} showLegend={true} width={300} + xDomain={ + Array [ + 1466420890000, + 1466424490000, + ] + } /> ATM snapshot test 1`] = ` } name="Error rate, %" width={300} + xDomain={ + Array [ + 1466420890000, + 1466424490000, + ] + } yDomain={ Array [ 0, @@ -239,6 +251,12 @@ exports[` ATM snapshot test 1`] = ` name="Request rate, req/s" showHorizontalLines={true} width={300} + xDomain={ + Array [ + 1466420890000, + 1466424490000, + ] + } /> @@ -335,7 +353,7 @@ exports[` ATM snapshot test 1`] = ` }, ] } - endTime={1487076708000} + endTime={1466424490000} error={ Object { "opsCalls": null, diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/index.test.js b/packages/jaeger-ui/src/components/Monitor/ServicesView/index.test.js index 0be788968f..3434f6d1ba 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/index.test.js +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/index.test.js @@ -40,6 +40,9 @@ describe('', () => { const mockFetchServices = jest.fn(); const mockFetchAllServiceMetrics = jest.fn(); const mockFetchAggregatedServiceMetrics = jest.fn(); + beforeAll(() => { + Date.now = jest.fn(() => 1466424490000); + }); beforeEach(() => { wrapper = shallow( @@ -54,6 +57,7 @@ describe('', () => { afterEach(() => { wrapper = null; + jest.clearAllMocks(); }); diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/index.tsx b/packages/jaeger-ui/src/components/Monitor/ServicesView/index.tsx index 3b9ccb1309..ee87b2b86c 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/index.tsx +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/index.tsx @@ -89,6 +89,7 @@ export const getLoopbackInterval = (interval: number) => { // export for tests export class MonitorATMServicesViewImpl extends React.PureComponent { graphDivWrapper: React.RefObject; + graphXDomain: number[]; serviceSelectorValue: string = ''; endTime: number = Date.now(); state = { @@ -100,6 +101,9 @@ export class MonitorATMServicesViewImpl extends React.PureComponent @@ -264,6 +269,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent @@ -277,6 +283,7 @@ export class MonitorATMServicesViewImpl extends React.PureComponent diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/serviceGraph.tsx b/packages/jaeger-ui/src/components/Monitor/ServicesView/serviceGraph.tsx index 57bc63e14e..1328a0450e 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/serviceGraph.tsx +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/serviceGraph.tsx @@ -41,6 +41,7 @@ type TProps = { yDomain?: number[]; color?: string; marginClassName?: string; + xDomain: number[]; }; type TCrossHairValues = { @@ -145,6 +146,7 @@ export class ServiceGraphImpl extends React.PureComponent { marginClassName, name, error, + xDomain, } = this.props; let GraphComponent = this.generatePlaceholder(); const noDataComponent = this.generatePlaceholder('No Data'); @@ -156,6 +158,7 @@ export class ServiceGraphImpl extends React.PureComponent { onMouseLeave={() => this.setState({ crosshairValues: [] })} width={width} height={this.height - 74} + xDomain={xDomain} yDomain={yDomain} > {showHorizontalLines ? : null}