Skip to content

Commit

Permalink
[APM] Transactions breakdown graph: Add breakdown KPI component (#38658)
Browse files Browse the repository at this point in the history
* [APM] Transactions breakdown graph: Add breakdown KPI component

Closes #36445.

* Remove percentage, line wrapping, correct query

* Add transaction breakdown chart to transaction details page

* Move files into new plugin dir

* Add empty state; update labels

* Use new mapping

* Move urlParams to useTransactionBreakdown hook

* Fix types

* Only show empty state in TransactionBreakdown if previously data was rendered

* Restrict no of KPIs to 20

* Use ternary in render of TransactionBreakdownHeader for consistency
  • Loading branch information
dgieselaar authored Jun 28, 2019
1 parent caae025 commit 3512463
Show file tree
Hide file tree
Showing 20 changed files with 769 additions and 27 deletions.
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 ? (
<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>
) : null}
</EuiFlexGroup>
);
};

export { TransactionBreakdownHeader };
Loading

0 comments on commit 3512463

Please sign in to comment.