From d0da3a5755343c3a51d01ae2a675a61ea16054f9 Mon Sep 17 00:00:00 2001 From: nofar9792 Date: Mon, 31 Jan 2022 15:01:36 +0200 Subject: [PATCH] Request rate Signed-off-by: nofar9792 --- .../__snapshots__/index.test.js.snap | 1382 ++++++++++++++++- .../operationDetailsTable/index.test.js | 16 + .../operationDetailsTable/index.tsx | 11 +- 3 files changed, 1407 insertions(+), 2 deletions(-) diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/__snapshots__/index.test.js.snap b/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/__snapshots__/index.test.js.snap index 1222d27460..2aa868cff3 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/__snapshots__/index.test.js.snap +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/__snapshots__/index.test.js.snap @@ -418,6 +418,1386 @@ exports[` render No data table 1`] = ` `; +exports[` render greater than 0.1 requests value in the table 1`] = ` +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Name +
+ + + + + + +
+
+
+ + P95 Latency +
+ + + + + + +
+
+
+ + Request rate +
+ + + + + + +
+
+
+ + Error rate +
+ + + + + + +
+
+
+ +
+ + Impact   + + +
+
+ + + + + + +
+
+
+ + /PlaceOrder + +
+
+
+ + + + +
+
+
+ 736.16 ms +
+
+
+
+
+
+ + + + +
+
+
+ 0.2 req/s +
+
+
+
+
+
+ + + + +
+
+
+ 1% +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+`; + +exports[` render number with more than 2 decimal places value in the table 1`] = ` + +`; + exports[` render some values in the table 1`] = `
render some values in the table 1`] = `
- 0.01 req/s + < 0.1 req/s
diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.test.js b/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.test.js index 7dacc5751e..cddac49a37 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.test.js +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.test.js @@ -75,6 +75,22 @@ describe('', () => { expect(wrapper).toMatchSnapshot(); }); + it('render greater than 0.1 requests value in the table', () => { + const cloneServiceOpsMetrics = {}; + Object.assign(cloneServiceOpsMetrics, serviceOpsMetrics[0]); + cloneServiceOpsMetrics.requests = 0.2; + wrapper.setProps({ ...props, data: [cloneServiceOpsMetrics], loading: false }); + expect(wrapper).toMatchSnapshot(); + }); + + it('render number with more than 2 decimal places value in the table', () => { + const cloneServiceOpsMetrics = {}; + Object.assign(cloneServiceOpsMetrics, serviceOpsMetrics[0]); + cloneServiceOpsMetrics.requests = 0.2888; + wrapper.setProps({ ...props, data: [cloneServiceOpsMetrics], loading: false }); + expect(wrapper).toMatchSnapshot(); + }); + it('test column render function', () => { wrapper.setProps({ ...props, diff --git a/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.tsx b/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.tsx index 002e6fd15c..ddec31fcc0 100644 --- a/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.tsx +++ b/packages/jaeger-ui/src/components/Monitor/ServicesView/operationDetailsTable/index.tsx @@ -34,6 +34,15 @@ type TState = { hoveredRowKey: number; }; +function formatValue(value: number) { + if (value < 0.1) { + return `< 0.1 req/s`; + } + + // Truncate number to two decimal places + return `${value.toString().match(/^-?\d+(?:\.\d{0,2})?/)![0]} req/s`; +} + export class OperationTableDetails extends React.PureComponent { state = { hoveredRowKey: -1, @@ -94,7 +103,7 @@ export class OperationTableDetails extends React.PureComponent { />
{typeof value === 'number' && row.dataPoints.service_operation_call_rate.length > 0 - ? `${value} req/s` + ? `${formatValue(value)}` : ''}