-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Performance comparison charts by user agent (browser) (#49582)
Show a chart with average page load broken down by user agent name on the RUM overview. I tested this by setting up a RUM agent on a sample app on my test cloud cluster. On the internal APM dev cluster you'll need to set the time range to about 90 days then look at the "client" app and find the time range where there are requests. Unfortunately with this sample data the only series you see is "Other" because there aren't a lot of requests. Also factor out the color selection into a common helper. Fixes #43342
- Loading branch information
Showing
26 changed files
with
605 additions
and
89 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
x-pack/legacy/plugins/apm/common/__snapshots__/elasticsearch_fieldnames.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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 lightTheme from '@elastic/eui/dist/eui_theme_light.json'; | ||
|
||
function getVizColorsForTheme(theme = lightTheme) { | ||
return [ | ||
theme.euiColorVis0, | ||
theme.euiColorVis1, | ||
theme.euiColorVis2, | ||
theme.euiColorVis3, | ||
theme.euiColorVis4, | ||
theme.euiColorVis5, | ||
theme.euiColorVis6, | ||
theme.euiColorVis7, | ||
theme.euiColorVis8, | ||
theme.euiColorVis9 | ||
]; | ||
} | ||
|
||
export function getVizColorForIndex(index = 0, theme = lightTheme) { | ||
const colors = getVizColorsForTheme(theme); | ||
return colors[index % colors.length]; | ||
} |
17 changes: 17 additions & 0 deletions
17
...y/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.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,17 @@ | ||
/* | ||
* 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 } from 'enzyme'; | ||
import { BrowserLineChart } from './BrowserLineChart'; | ||
|
||
describe('BrowserLineChart', () => { | ||
describe('render', () => { | ||
it('renders', () => { | ||
expect(() => shallow(<BrowserLineChart />)).not.toThrowError(); | ||
}); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
...legacy/plugins/apm/public/components/shared/charts/TransactionCharts/BrowserLineChart.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,45 @@ | ||
/* | ||
* 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 { EuiTitle } from '@elastic/eui'; | ||
import { TransactionLineChart } from './TransactionLineChart'; | ||
import { | ||
getMaxY, | ||
getResponseTimeTickFormatter, | ||
getResponseTimeTooltipFormatter | ||
} from '.'; | ||
import { getDurationFormatter } from '../../../../utils/formatters'; | ||
import { useAvgDurationByBrowser } from '../../../../hooks/useAvgDurationByBrowser'; | ||
|
||
export function BrowserLineChart() { | ||
const { data } = useAvgDurationByBrowser(); | ||
const maxY = getMaxY(data); | ||
const formatter = getDurationFormatter(maxY); | ||
const formatTooltipValue = getResponseTimeTooltipFormatter(formatter); | ||
const tickFormatY = getResponseTimeTickFormatter(formatter); | ||
|
||
return ( | ||
<> | ||
<EuiTitle size="xs"> | ||
<span> | ||
{i18n.translate( | ||
'xpack.apm.metrics.pageLoadCharts.avgPageLoadByBrowser', | ||
{ | ||
defaultMessage: 'Avg. page load duration distribution by browser' | ||
} | ||
)} | ||
</span> | ||
</EuiTitle> | ||
<TransactionLineChart | ||
formatTooltipValue={formatTooltipValue} | ||
series={data} | ||
tickFormatY={tickFormatY} | ||
/> | ||
</> | ||
); | ||
} |
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
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
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
33 changes: 33 additions & 0 deletions
33
x-pack/legacy/plugins/apm/public/hooks/useAvgDurationByBrowser.test.ts
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,33 @@ | ||
/* | ||
* 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 { renderHook } from 'react-hooks-testing-library'; | ||
import theme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import * as useFetcherModule from './useFetcher'; | ||
import { useAvgDurationByBrowser } from './useAvgDurationByBrowser'; | ||
|
||
describe('useAvgDurationByBrowser', () => { | ||
it('returns data', () => { | ||
const data = [ | ||
{ title: 'Other', data: [{ x: 1572530100000, y: 130010.8947368421 }] } | ||
]; | ||
jest.spyOn(useFetcherModule, 'useFetcher').mockReturnValueOnce({ | ||
data, | ||
refetch: () => {}, | ||
status: 'success' as useFetcherModule.FETCH_STATUS | ||
}); | ||
const { result } = renderHook(() => useAvgDurationByBrowser()); | ||
|
||
expect(result.current.data).toEqual([ | ||
{ | ||
color: theme.euiColorVis0, | ||
data: [{ x: 1572530100000, y: 130010.8947368421 }], | ||
title: 'Other', | ||
type: 'linemark' | ||
} | ||
]); | ||
}); | ||
}); |
Oops, something went wrong.