Skip to content

Commit 287c153

Browse files
authored
[APM] Errors table for service overview (#83065) (#83291)
1 parent aec05c4 commit 287c153

File tree

17 files changed

+883
-63
lines changed

17 files changed

+883
-63
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
import * as t from 'io-ts';
7+
8+
export const toNumberRt = new t.Type<number, unknown, unknown>(
9+
'ToNumber',
10+
t.any.is,
11+
(input, context) => {
12+
const number = Number(input);
13+
return !isNaN(number) ? t.success(number) : t.failure(input, context);
14+
},
15+
t.identity
16+
);

x-pack/plugins/apm/public/components/app/service_inventory/ServiceList/ServiceListMetric.tsx

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
7-
import { EuiFlexItem } from '@elastic/eui';
8-
import { EuiFlexGroup } from '@elastic/eui';
9-
106
import React from 'react';
11-
import { useTheme } from '../../../../hooks/useTheme';
127
import { useUrlParams } from '../../../../hooks/useUrlParams';
13-
import { getEmptySeries } from '../../../shared/charts/CustomPlot/getEmptySeries';
14-
import { SparkPlot } from '../../../shared/charts/SparkPlot';
8+
import { SparkPlotWithValueLabel } from '../../../shared/charts/spark_plot/spark_plot_with_value_label';
159

1610
export function ServiceListMetric({
1711
color,
@@ -22,28 +16,17 @@ export function ServiceListMetric({
2216
series?: Array<{ x: number; y: number | null }>;
2317
valueLabel: React.ReactNode;
2418
}) {
25-
const theme = useTheme();
26-
2719
const {
2820
urlParams: { start, end },
2921
} = useUrlParams();
3022

31-
const colorValue = theme.eui[color];
32-
3323
return (
34-
<EuiFlexGroup gutterSize="m">
35-
<EuiFlexItem grow={false}>
36-
<SparkPlot
37-
series={
38-
series ??
39-
getEmptySeries(parseFloat(start!), parseFloat(end!))[0].data
40-
}
41-
color={colorValue}
42-
/>
43-
</EuiFlexItem>
44-
<EuiFlexItem grow={false} style={{ whiteSpace: 'nowrap' }}>
45-
{valueLabel}
46-
</EuiFlexItem>
47-
</EuiFlexGroup>
24+
<SparkPlotWithValueLabel
25+
start={parseFloat(start!)}
26+
end={parseFloat(end!)}
27+
valueLabel={valueLabel}
28+
series={series}
29+
color={color}
30+
/>
4831
);
4932
}

x-pack/plugins/apm/public/components/app/service_overview/index.tsx

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import { useTrackPageview } from '../../../../../observability/public';
1212
import { isRumAgentName } from '../../../../common/agent_name';
1313
import { ChartsSyncContextProvider } from '../../../context/charts_sync_context';
1414
import { TransactionErrorRateChart } from '../../shared/charts/transaction_error_rate_chart';
15-
import { ErrorOverviewLink } from '../../shared/Links/apm/ErrorOverviewLink';
1615
import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink';
1716
import { TransactionOverviewLink } from '../../shared/Links/apm/TransactionOverviewLink';
17+
import { ServiceOverviewErrorsTable } from './service_overview_errors_table';
18+
import { TableLinkFlexItem } from './table_link_flex_item';
1819

1920
const rowHeight = 310;
2021
const latencyChartRowHeight = 230;
@@ -27,12 +28,6 @@ const LatencyChartRow = styled(EuiFlexItem)`
2728
height: ${latencyChartRowHeight}px;
2829
`;
2930

30-
const TableLinkFlexItem = styled(EuiFlexItem)`
31-
& > a {
32-
text-align: right;
33-
}
34-
`;
35-
3631
interface ServiceOverviewProps {
3732
agentName?: string;
3833
serviceName: string;
@@ -130,30 +125,7 @@ export function ServiceOverview({
130125
)}
131126
<EuiFlexItem grow={6}>
132127
<EuiPanel>
133-
<EuiFlexGroup>
134-
<EuiFlexItem>
135-
<EuiTitle size="xs">
136-
<h2>
137-
{i18n.translate(
138-
'xpack.apm.serviceOverview.errorsTableTitle',
139-
{
140-
defaultMessage: 'Errors',
141-
}
142-
)}
143-
</h2>
144-
</EuiTitle>
145-
</EuiFlexItem>
146-
<TableLinkFlexItem>
147-
<ErrorOverviewLink serviceName={serviceName}>
148-
{i18n.translate(
149-
'xpack.apm.serviceOverview.errorsTableLinkText',
150-
{
151-
defaultMessage: 'View errors',
152-
}
153-
)}
154-
</ErrorOverviewLink>
155-
</TableLinkFlexItem>
156-
</EuiFlexGroup>
128+
<ServiceOverviewErrorsTable serviceName={serviceName} />
157129
</EuiPanel>
158130
</EuiFlexItem>
159131
</EuiFlexGroup>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
import React from 'react';
8+
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
9+
import { ErrorStatePrompt } from '../../../shared/ErrorStatePrompt';
10+
import { LoadingStatePrompt } from '../../../shared/LoadingStatePrompt';
11+
12+
export function FetchWrapper({
13+
hasData,
14+
status,
15+
children,
16+
}: {
17+
hasData: boolean;
18+
status: FETCH_STATUS;
19+
children: React.ReactNode;
20+
}) {
21+
if (status === FETCH_STATUS.FAILURE) {
22+
return <ErrorStatePrompt />;
23+
}
24+
25+
if (!hasData && status !== FETCH_STATUS.SUCCESS) {
26+
return <LoadingStatePrompt />;
27+
}
28+
29+
return <>{children}</>;
30+
}

0 commit comments

Comments
 (0)