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

[APM] Service overview: Errors table #83065

Merged
merged 7 commits into from
Nov 12, 2020
16 changes: 16 additions & 0 deletions x-pack/plugins/apm/common/runtime_types/to_number_rt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import * as t from 'io-ts';

export const toNumberRt = new t.Type<number, unknown, unknown>(
'ToNumber',
t.any.is,
(input, context) => {
const number = Number(input);
return !isNaN(number) ? t.success(number) : t.failure(input, context);
},
t.identity
);
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiFlexItem } from '@elastic/eui';
import { EuiFlexGroup } from '@elastic/eui';

import React from 'react';
import { useTheme } from '../../../../hooks/useTheme';
import { useUrlParams } from '../../../../hooks/useUrlParams';
import { getEmptySeries } from '../../../shared/charts/CustomPlot/getEmptySeries';
import { SparkPlot } from '../../../shared/charts/SparkPlot';
import { SparkPlotWithValueLabel } from '../../../shared/charts/spark_plot/spark_plot_with_value_label';

export function ServiceListMetric({
color,
Expand All @@ -22,28 +16,17 @@ export function ServiceListMetric({
series?: Array<{ x: number; y: number | null }>;
valueLabel: React.ReactNode;
}) {
const theme = useTheme();

const {
urlParams: { start, end },
} = useUrlParams();

const colorValue = theme.eui[color];

return (
<EuiFlexGroup gutterSize="m">
<EuiFlexItem grow={false}>
<SparkPlot
series={
series ??
getEmptySeries(parseFloat(start!), parseFloat(end!))[0].data
}
color={colorValue}
/>
</EuiFlexItem>
<EuiFlexItem grow={false} style={{ whiteSpace: 'nowrap' }}>
{valueLabel}
</EuiFlexItem>
</EuiFlexGroup>
<SparkPlotWithValueLabel
start={parseFloat(start!)}
end={parseFloat(end!)}
valueLabel={valueLabel}
series={series}
color={color}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { useTrackPageview } from '../../../../../observability/public';
import { isRumAgentName } from '../../../../common/agent_name';
import { ChartsSyncContextProvider } from '../../../context/charts_sync_context';
import { TransactionErrorRateChart } from '../../shared/charts/transaction_error_rate_chart';
import { ErrorOverviewLink } from '../../shared/Links/apm/ErrorOverviewLink';
import { ServiceMapLink } from '../../shared/Links/apm/ServiceMapLink';
import { TransactionOverviewLink } from '../../shared/Links/apm/TransactionOverviewLink';
import { ServiceOverviewErrorsTable } from './service_overview_errors_table';
import { TableLinkFlexItem } from './table_link_flex_item';

const rowHeight = 310;
const latencyChartRowHeight = 230;
Expand All @@ -27,12 +28,6 @@ const LatencyChartRow = styled(EuiFlexItem)`
height: ${latencyChartRowHeight}px;
`;

const TableLinkFlexItem = styled(EuiFlexItem)`
& > a {
text-align: right;
}
`;

interface ServiceOverviewProps {
agentName?: string;
serviceName: string;
Expand Down Expand Up @@ -130,30 +125,7 @@ export function ServiceOverview({
)}
<EuiFlexItem grow={6}>
<EuiPanel>
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="xs">
<h2>
{i18n.translate(
'xpack.apm.serviceOverview.errorsTableTitle',
{
defaultMessage: 'Errors',
}
)}
</h2>
</EuiTitle>
</EuiFlexItem>
<TableLinkFlexItem>
<ErrorOverviewLink serviceName={serviceName}>
{i18n.translate(
'xpack.apm.serviceOverview.errorsTableLinkText',
{
defaultMessage: 'View errors',
}
)}
</ErrorOverviewLink>
</TableLinkFlexItem>
</EuiFlexGroup>
<ServiceOverviewErrorsTable serviceName={serviceName} />
</EuiPanel>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { FETCH_STATUS } from '../../../../hooks/useFetcher';
import { ErrorStatePrompt } from '../../../shared/ErrorStatePrompt';
import { LoadingStatePrompt } from '../../../shared/LoadingStatePrompt';

export function FetchWrapper({
hasData,
status,
children,
}: {
hasData: boolean;
status: FETCH_STATUS;
children: React.ReactNode;
}) {
if (status === FETCH_STATUS.FAILURE) {
return <ErrorStatePrompt />;
}

if (!hasData && status !== FETCH_STATUS.SUCCESS) {
return <LoadingStatePrompt />;
}

return <>{children}</>;
}
Loading