Skip to content

Commit

Permalink
Monitor Tab - show 95 Latency in a more readable time-unit (#893)
Browse files Browse the repository at this point in the history
* Unit time

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

* Use timeConversion

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

* Lower case

Signed-off-by: nofar9792 <nofar.cohen@logz.io>
  • Loading branch information
nofar9792 committed Feb 28, 2022
1 parent fefb034 commit 7294884
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ exports[`<OperationTableDetails> render greater than 0.1 requests value in the t
<div
className="table-graph-avg"
>
736.16 ms
736ms
</div>
</div>
</td>
Expand Down Expand Up @@ -1489,7 +1489,7 @@ exports[`<OperationTableDetails> render number with more than 2 decimal places v
<div
className="table-graph-avg"
>
736.16 ms
736ms
</div>
</div>
</td>
Expand Down Expand Up @@ -2179,7 +2179,7 @@ exports[`<OperationTableDetails> render some values in the table 1`] = `
<div
className="table-graph-avg"
>
736.16 ms
736ms
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ describe('<OperationTableDetails>', () => {
expect(wrapper).toMatchSnapshot();
});

it('render latency in seconds in the table', () => {
const cloneServiceOpsMetrics = {};
Object.assign(cloneServiceOpsMetrics, serviceOpsMetrics[0]);
cloneServiceOpsMetrics.latency = 8000;
});

it('render greater than 0.1 requests value in the table', () => {
const cloneServiceOpsMetrics = {};
Object.assign(cloneServiceOpsMetrics, serviceOpsMetrics[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { MetricsReduxState, ServiceOpsMetrics } from '../../../../types/metrics'
import prefixUrl from '../../../../utils/prefix-url';

import './index.css';
import { timeConversion } from '../../../../utils/date';

type TProps = {
data: ServiceOpsMetrics[] | undefined;
Expand Down Expand Up @@ -82,7 +83,7 @@ export class OperationTableDetails extends React.PureComponent<TProps, TState> {
/>
<div className="table-graph-avg">
{typeof value === 'number' && row.dataPoints.service_operation_latencies.length > 0
? `${value} ms`
? timeConversion(value * 1000)
: ''}
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/jaeger-ui/src/utils/date.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ describe('timeConversion', () => {
});
it('displays time in seconds', () => {
const input = 5000000;
expect(timeConversion(input)).toBe('5Sec');
expect(timeConversion(input)).toBe('5s');
});
it('displays time in mintues', () => {
const input = 120000000;
expect(timeConversion(input)).toBe('2Min');
expect(timeConversion(input)).toBe('2m');
});
it('displays time in hours', () => {
const input = 7200000000;
expect(timeConversion(input)).toBe('2Hrs');
expect(timeConversion(input)).toBe('2h');
});
it('displays time in days', () => {
const input = 172800000000;
expect(timeConversion(input)).toBe('2Days');
expect(timeConversion(input)).toBe('2d');
});
});
8 changes: 4 additions & 4 deletions packages/jaeger-ui/src/utils/date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ export function timeConversion(microseconds: number) {
} else if (milliseconds < 1000) {
timeText = `${milliseconds}ms`;
} else if (seconds < 60) {
timeText = `${seconds}Sec`;
timeText = `${seconds}s`;
} else if (minutes < 60) {
timeText = `${minutes}Min`;
timeText = `${minutes}m`;
} else if (hours < 24) {
timeText = `${hours}Hrs`;
timeText = `${hours}h`;
} else {
timeText = `${days}Days`;
timeText = `${days}d`;
}
return timeText;
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13057,9 +13057,9 @@ url-loader@1.1.2:
schema-utils "^1.0.0"

url-parse@^1.1.8, url-parse@^1.4.3:
version "1.5.10"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1"
integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==
version "1.5.7"
resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.7.tgz#00780f60dbdae90181f51ed85fb24109422c932a"
integrity sha512-HxWkieX+STA38EDk7CE9MEryFeHCKzgagxlGvsdS7WBImq9Mk+PGwiT56w82WI3aicwJA8REp42Cxo98c8FZMA==
dependencies:
querystringify "^2.1.1"
requires-port "^1.0.0"
Expand Down

0 comments on commit 7294884

Please sign in to comment.