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] Transactions breakdown graph: Add breakdown KPI component #38658

Merged
merged 11 commits into from
Jun 28, 2019
10 changes: 6 additions & 4 deletions x-pack/legacy/plugins/apm/public/components/app/Main/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ import { TraceOverview } from '../TraceOverview';
const homeTabs: IHistoryTab[] = [
{
path: '/services',
name: i18n.translate('xpack.apm.home.servicesTabLabel', {
title: i18n.translate('xpack.apm.home.servicesTabLabel', {
defaultMessage: 'Services'
}),
render: () => <ServiceOverview />
render: () => <ServiceOverview />,
name: 'services'
},
{
path: '/traces',
name: i18n.translate('xpack.apm.home.tracesTabLabel', {
title: i18n.translate('xpack.apm.home.tracesTabLabel', {
defaultMessage: 'Traces'
}),
render: () => <TraceOverview />
render: () => <TraceOverview />,
name: 'traces'
}
];

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function ServiceDetailTabs({
const { serviceName } = urlParams;
const headTransactionType = transactionTypes[0];
const transactionsTab = {
name: i18n.translate('xpack.apm.serviceDetails.transactionsTabLabel', {
title: i18n.translate('xpack.apm.serviceDetails.transactionsTabLabel', {
defaultMessage: 'Transactions'
}),
path: headTransactionType
Expand All @@ -42,23 +42,28 @@ export function ServiceDetailTabs({
urlParams={urlParams}
serviceTransactionTypes={transactionTypes}
/>
)
),
name: 'transactions'
};
const errorsTab = {
name: i18n.translate('xpack.apm.serviceDetails.errorsTabLabel', {
title: i18n.translate('xpack.apm.serviceDetails.errorsTabLabel', {
defaultMessage: 'Errors'
}),
path: `/${serviceName}/errors`,
render: () => {
return <ErrorGroupOverview urlParams={urlParams} location={location} />;
}
},
name: 'errors'
};
const metricsTab = {
name: i18n.translate('xpack.apm.serviceDetails.metricsTabLabel', {
title: i18n.translate('xpack.apm.serviceDetails.metricsTabLabel', {
defaultMessage: 'Metrics'
}),
path: `/${serviceName}/metrics`,
render: () => <ServiceMetrics urlParams={urlParams} agentName={agentName} />
render: () => (
<ServiceMetrics urlParams={urlParams} agentName={agentName} />
),
name: 'metrics'
};
const tabs = isRumAgent
? [transactionsTab, errorsTab]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Transaction } from './Transaction';
import { useLocation } from '../../../hooks/useLocation';
import { useUrlParams } from '../../../hooks/useUrlParams';
import { FETCH_STATUS } from '../../../hooks/useFetcher';
import { TransactionBreakdown } from '../../shared/TransactionBreakdown';

export function TransactionDetails() {
const location = useLocation();
Expand All @@ -31,14 +32,18 @@ export function TransactionDetails() {
const { data: waterfall } = useWaterfall(urlParams);
const transaction = waterfall.getTransactionById(urlParams.transactionId);

const { transactionName } = urlParams;

return (
<div>
<ApmHeader>
<EuiTitle size="l">
<h1>{urlParams.transactionName}</h1>
<h1>{transactionName}</h1>
</EuiTitle>
</ApmHeader>

<TransactionBreakdown />

<EuiSpacer size="s" />

<TransactionCharts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useTransactionList } from '../../../hooks/useTransactionList';
import { useTransactionOverviewCharts } from '../../../hooks/useTransactionOverviewCharts';
import { IUrlParams } from '../../../context/UrlParamsContext/types';
import { TransactionCharts } from '../../shared/charts/TransactionCharts';
import { TransactionBreakdown } from '../../shared/TransactionBreakdown';
import { legacyEncodeURIComponent } from '../../shared/Links/url_helpers';
import { TransactionList } from './List';
import { useRedirect } from './useRedirect';
Expand Down Expand Up @@ -113,6 +114,10 @@ export function TransactionOverview({
</EuiFormRow>
) : null}

<TransactionBreakdown />

<EuiSpacer size="s" />

<TransactionCharts
hasMLJob={hasMLJob}
charts={transactionOverviewCharts}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ describe('HistoryTabs', () => {

testTabs = [
{
name: 'One',
name: 'one',
title: 'One',
path: '/one',
render: props => <Content {...props} name="one" />
},
{
name: 'Two',
name: 'two',
title: 'Two',
path: '/two',
render: () => <Content name="two" />
},
{
name: 'Three',
name: 'three',
title: 'Three',
path: '/three',
render: () => <Content name="three" />
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { history } from '../../../utils/history';
export interface IHistoryTab {
path: string;
routePath?: string;
name: React.ReactNode;
title: React.ReactNode;
name: string;
render?: (props: RouteComponentProps) => React.ReactNode;
}

Expand All @@ -37,9 +38,9 @@ export function HistoryTabs({ tabs }: HistoryTabsProps) {
<EuiTab
onClick={() => history.push({ ...location, pathname: tab.path })}
isSelected={isTabSelected(tab, location.pathname)}
key={`${tab.path}--${i}`}
key={tab.name}
>
{tab.name}
{tab.title}
</EuiTab>
))}
</EuiTabs>
Expand All @@ -49,7 +50,7 @@ export function HistoryTabs({ tabs }: HistoryTabsProps) {
<Route
path={tab.routePath || tab.path}
render={tab.render}
key={tab.path}
key={tab.name}
/>
) : null
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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';

const TransactionBreakdownGraph: React.FC<{}> = () => {
return <div />;
};

export { TransactionBreakdownGraph };
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* 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 {
EuiTitle,
EuiFlexGroup,
EuiFlexItem,
EuiSpacer,
EuiBetaBadge,
EuiButtonEmpty
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';

const TransactionBreakdownHeader: React.FC<{
showChart: boolean;
hideShowChartButton: boolean;
onToggleClick: () => void;
}> = ({ showChart, onToggleClick, hideShowChartButton }) => {
return (
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle size="xs">
<h3>
<EuiFlexGroup alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
{i18n.translate('xpack.apm.transactionBreakdown.chartTitle', {
defaultMessage: 'Time spent by span type'
})}
</EuiFlexItem>
<EuiSpacer size="xs" />
<EuiFlexItem grow={false}>
<EuiBetaBadge
label={i18n.translate('xpack.apm.ui.betaBadgeLabel', {
defaultMessage: 'Beta'
})}
tooltipContent={i18n.translate(
'xpack.apm.ui.betaBadgeTooltipTitle',
{
defaultMessage:
'This feature is still in development. If you have feedback, please reach out in our Discuss forum.'
}
)}
/>
</EuiFlexItem>
</EuiFlexGroup>
</h3>
</EuiTitle>
</EuiFlexItem>
{!hideShowChartButton && (
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to use the ternary pattern in JSX composition just to be consistent:

{!hideShowChartButton ? (...) : null}

Copy link
Member Author

Choose a reason for hiding this comment

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

aye, fixed

<EuiFlexItem grow={false}>
<EuiButtonEmpty
size="xs"
iconType={showChart ? 'arrowDown' : 'arrowRight'}
onClick={() => onToggleClick()}
>
{showChart
? i18n.translate('xpack.apm.transactionBreakdown.hideChart', {
defaultMessage: 'Hide chart'
})
: i18n.translate('xpack.apm.transactionBreakdown.showChart', {
defaultMessage: 'Show chart'
})}
</EuiButtonEmpty>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
};

export { TransactionBreakdownHeader };
Loading