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

[Uptime] handle null duration on ping list #125438

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions x-pack/plugins/uptime/common/runtime_types/ping/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ export type Tls = t.TypeOf<typeof TlsType>;

export const MonitorType = t.intersection([
t.type({
duration: t.type({
us: t.number,
}),
id: t.string,
status: t.string,
type: t.string,
}),
t.partial({
duration: t.type({
us: t.number,
}),
check_group: t.string,
ip: t.string,
name: t.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('PingList component', () => {
type: 'io',
},
monitor: {
duration: { us: 1370 },
id: 'auto-tcp-0X81440A68E839814D',
ip: '255.255.255.0',
name: '',
Expand Down Expand Up @@ -161,9 +160,6 @@ describe('PingList component', () => {
"type": "io",
},
"monitor": Object {
"duration": Object {
"us": 1370,
},
"id": "auto-tcp-0X81440A68E839814D",
"ip": "255.255.255.0",
"name": "",
Expand All @@ -186,6 +182,13 @@ describe('PingList component', () => {
});
});

describe('duration column', () => {
it('shows -- when duration is null', () => {
const { getByTestId } = render(<PingList />);
expect(getByTestId('ping-list-duration-unavailable-tool-tip')).toBeInTheDocument();
});
});

describe('formatDuration', () => {
it('returns zero for < 1 millisecond', () => {
expect(formatDuration(984)).toBe('0 ms');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { MouseEvent, useCallback, useEffect, useState } from 'react';
import { EuiBasicTable } from '@elastic/eui';
import { EuiBasicTable, EuiToolTip } from '@elastic/eui';
dominiqueclarke marked this conversation as resolved.
Show resolved Hide resolved
import { i18n } from '@kbn/i18n';
import moment from 'moment';
import { useHistory } from 'react-router-dom';
Expand Down Expand Up @@ -140,7 +140,18 @@ export function PingListTable({ loading, error, pings, pagination, onChange, fai
name: i18n.translate('xpack.uptime.pingList.durationMsColumnLabel', {
defaultMessage: 'Duration',
}),
render: (duration: number) => formatDuration(duration),
render: (duration: number | null) =>
duration ? (
formatDuration(duration)
) : (
<EuiToolTip
content={i18n.translate('xpack.uptime.pingList.durationColumnToolTip', {
defaultMessage: 'Duration is unavailable for journeys that do not finish executing',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this logic ever apply to lightweight checks? The content I have now is very specific to journeys

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better to keep error not specific to journeys? Or even keep it as '--'

})}
>
<span data-test-subj="ping-list-duration-unavailable-tool-tip">{'--'}</span>
</EuiToolTip>
dominiqueclarke marked this conversation as resolved.
Show resolved Hide resolved
),
},
...(hasError
? [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const MonitorListComponent: ({
timestamp={timestamp}
summaryPings={summaryPings ?? []}
monitorType={type}
duration={duration!.us}
duration={duration?.us}
monitorId={monitorId}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class ServiceAPIClient {
);
if (locMonitors.length > 0) {
promises.push(
rxjsFrom(callServiceEndpoint(locMonitors, url)).pipe(
rxjsFrom(callServiceEndpoint(locMonitors, `${url}-test`)).pipe(
dominiqueclarke marked this conversation as resolved.
Show resolved Hide resolved
tap((result) => {
this.logger.debug(result.data);
this.logger.debug(
Expand Down