forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] One-line trace summary (elastic#44842)
Replace the `StickyTransactionProperties` with a trace summary that puts everything on one line. Fixes elastic#43247.
- Loading branch information
Showing
17 changed files
with
594 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ins/apm/public/components/app/TransactionDetails/WaterfallWithSummmary/PercentOfTrace.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { EuiToolTip } from '@elastic/eui'; | ||
import { asPercent } from '../../../../utils/formatters'; | ||
|
||
interface PercentOfTraceProps { | ||
duration: number; | ||
totalDuration?: number; | ||
} | ||
|
||
export function PercentOfTrace({ | ||
duration, | ||
totalDuration | ||
}: PercentOfTraceProps) { | ||
totalDuration = totalDuration || duration; | ||
const isOver100 = duration > totalDuration; | ||
const percentOfTrace = isOver100 | ||
? '>100%' | ||
: asPercent(duration, totalDuration, ''); | ||
|
||
const percentOfTraceText = i18n.translate( | ||
'xpack.apm.transactionDetails.percentOfTrace', | ||
{ | ||
defaultMessage: '{value} of trace', | ||
values: { value: percentOfTrace } | ||
} | ||
); | ||
|
||
return ( | ||
<> | ||
{isOver100 ? ( | ||
<EuiToolTip | ||
content={i18n.translate( | ||
'xpack.apm.transactionDetails.percentOfTraceLabelExplanation', | ||
{ | ||
defaultMessage: | ||
'The % of trace exceeds 100% because this transaction takes longer than the root transaction.' | ||
} | ||
)} | ||
> | ||
<>{percentOfTraceText}</> | ||
</EuiToolTip> | ||
) : ( | ||
`(${percentOfTraceText})` | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../public/components/app/TransactionDetails/WaterfallWithSummmary/TraceSummary/Duration.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { EuiToolTip, EuiText } from '@elastic/eui'; | ||
import styled from 'styled-components'; | ||
import { asTime } from '../../../../../utils/formatters'; | ||
import { PercentOfTrace } from '../PercentOfTrace'; | ||
|
||
interface DurationProps { | ||
duration: number; | ||
totalDuration?: number; | ||
} | ||
|
||
const Span = styled('span')` | ||
white-space: nowrap; | ||
`; | ||
|
||
export function Duration({ duration, totalDuration }: DurationProps) { | ||
totalDuration = totalDuration || duration; | ||
const label = i18n.translate('xpack.apm.transactionDetails.durationLabel', { | ||
defaultMessage: 'Duration' | ||
}); | ||
|
||
return ( | ||
<Span> | ||
<EuiToolTip content={label}> | ||
<EuiText>{asTime(duration)}</EuiText> | ||
</EuiToolTip>{' '} | ||
<PercentOfTrace duration={duration} totalDuration={totalDuration} /> | ||
</Span> | ||
); | ||
} |
86 changes: 86 additions & 0 deletions
86
...ic/components/app/TransactionDetails/WaterfallWithSummmary/TraceSummary/HttpInfo.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* 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 { shallow, mount } from 'enzyme'; | ||
import { HttpInfo } from './HttpInfo'; | ||
import * as exampleTransactions from './__fixtures__/transactions'; | ||
import { palettes } from '@elastic/eui'; | ||
import { cloneDeep, set } from 'lodash'; | ||
|
||
describe('HttpInfo', () => { | ||
describe('render', () => { | ||
const transaction = exampleTransactions.httpOk; | ||
const url = 'https://example.com'; | ||
const props = { transaction, url }; | ||
|
||
it('renders', () => { | ||
expect(() => shallow(<HttpInfo {...props} />)).not.toThrowError(); | ||
}); | ||
|
||
describe('with status code 200', () => { | ||
it('shows a success color', () => { | ||
const wrapper = mount(<HttpInfo {...props} />); | ||
|
||
expect(wrapper.find('HttpStatusBadge EuiBadge').prop('color')).toEqual( | ||
palettes.euiPaletteForStatus.colors[0] | ||
); | ||
}); | ||
}); | ||
|
||
describe('with status code 301', () => { | ||
it('shows a warning color', () => { | ||
const p = cloneDeep(props); | ||
set(p, 'transaction.http.response.status_code', 301); | ||
|
||
const wrapper = mount(<HttpInfo {...p} />); | ||
|
||
expect(wrapper.find('HttpStatusBadge EuiBadge').prop('color')).toEqual( | ||
palettes.euiPaletteForStatus.colors[4] | ||
); | ||
}); | ||
}); | ||
|
||
describe('with status code 404', () => { | ||
it('shows a error color', () => { | ||
const p = cloneDeep(props); | ||
set(p, 'transaction.http.response.status_code', 404); | ||
|
||
const wrapper = mount(<HttpInfo {...p} />); | ||
|
||
expect(wrapper.find('HttpStatusBadge EuiBadge').prop('color')).toEqual( | ||
palettes.euiPaletteForStatus.colors[9] | ||
); | ||
}); | ||
}); | ||
|
||
describe('with status code 502', () => { | ||
it('shows a error color', () => { | ||
const p = cloneDeep(props); | ||
set(p, 'transaction.http.response.status_code', 502); | ||
|
||
const wrapper = mount(<HttpInfo {...p} />); | ||
|
||
expect(wrapper.find('HttpStatusBadge EuiBadge').prop('color')).toEqual( | ||
palettes.euiPaletteForStatus.colors[9] | ||
); | ||
}); | ||
}); | ||
|
||
describe('with some other status code', () => { | ||
it('shows the default color', () => { | ||
const p = cloneDeep(props); | ||
set(p, 'transaction.http.response.status_code', 700); | ||
|
||
const wrapper = mount(<HttpInfo {...p} />); | ||
|
||
expect(wrapper.find('HttpStatusBadge EuiBadge').prop('color')).toEqual( | ||
'default' | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
95 changes: 95 additions & 0 deletions
95
.../public/components/app/TransactionDetails/WaterfallWithSummmary/TraceSummary/HttpInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* 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 { EuiToolTip, EuiBadge } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import styled from 'styled-components'; | ||
import { idx } from '@kbn/elastic-idx/target'; | ||
import { palettes } from '@elastic/eui'; | ||
import { Transaction } from '../../../../../../typings/es_schemas/ui/Transaction'; | ||
import { units, px, truncate, unit } from '../../../../../style/variables'; | ||
import { statusCodes } from './statusCodes'; | ||
|
||
const statusColors = { | ||
success: palettes.euiPaletteForStatus.colors[0], | ||
warning: palettes.euiPaletteForStatus.colors[4], | ||
error: palettes.euiPaletteForStatus.colors[9] | ||
}; | ||
|
||
function getStatusColor(status: number) { | ||
const colors: { [key: string]: string } = { | ||
2: statusColors.success, | ||
3: statusColors.warning, | ||
4: statusColors.error, | ||
5: statusColors.error | ||
}; | ||
|
||
return colors[status.toString().substr(0, 1)] || 'default'; | ||
} | ||
|
||
interface HttpStatusBadgeProps { | ||
status: number; | ||
} | ||
function HttpStatusBadge({ status }: HttpStatusBadgeProps) { | ||
const label = i18n.translate('xpack.apm.transactionDetails.statusCode', { | ||
defaultMessage: 'Status code' | ||
}); | ||
|
||
return ( | ||
<EuiToolTip content={label}> | ||
<EuiBadge color={getStatusColor(status)}> | ||
{status} {statusCodes[status.toString()]} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
} | ||
|
||
const HttpInfoBadge = styled(EuiBadge)` | ||
margin-right: ${px(units.quarter)}; | ||
`; | ||
|
||
const Url = styled('span')` | ||
display: inline-block; | ||
vertical-align: bottom; | ||
${truncate(px(unit * 24))}; | ||
`; | ||
interface HttpInfoProps { | ||
transaction: Transaction; | ||
url: string; | ||
} | ||
|
||
const Span = styled('span')` | ||
white-space: nowrap; | ||
`; | ||
|
||
export function HttpInfo({ transaction, url }: HttpInfoProps) { | ||
const method = ( | ||
idx(transaction, _ => _.http.request.method) || '' | ||
).toUpperCase(); | ||
const status = idx(transaction, _ => _.http.response.status_code); | ||
|
||
const methodLabel = i18n.translate( | ||
'xpack.apm.transactionDetails.requestMethodLabel', | ||
{ | ||
defaultMessage: 'Request method' | ||
} | ||
); | ||
|
||
return ( | ||
<Span> | ||
<HttpInfoBadge title={undefined}> | ||
<EuiToolTip content={methodLabel}> | ||
<strong>{method}</strong> | ||
</EuiToolTip>{' '} | ||
<EuiToolTip content={url}> | ||
<Url>{url}</Url> | ||
</EuiToolTip> | ||
</HttpInfoBadge> | ||
{status && <HttpStatusBadge status={status} />} | ||
</Span> | ||
); | ||
} |
27 changes: 27 additions & 0 deletions
27
...pm/public/components/app/TransactionDetails/WaterfallWithSummmary/TraceSummary/Result.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 { EuiToolTip, EuiBadge } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
interface ResultProps { | ||
result: string; | ||
} | ||
|
||
export function Result({ result }: ResultProps) { | ||
return ( | ||
<EuiToolTip | ||
content={i18n.translate('xpack.apm.transactionDetails.resultLabel', { | ||
defaultMessage: 'Result' | ||
})} | ||
> | ||
<EuiBadge color="default" title={undefined}> | ||
{result} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
} |
Oops, something went wrong.