Skip to content

Commit

Permalink
[UX] Add median/percentile info in titles (#79824)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
shahzad31 and kibanamachine authored Oct 28, 2020
1 parent 82cf8fd commit e3f9649
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 263 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/e2e/cypress/integration/snapshots.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
"__version": "4.9.0"
"__version": "5.5.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Then(`it displays top pages in the suggestion popover`, () => {
listOfUrls.should('have.length', 5);

const actualUrlsText = [
'http://opbeans-node:3000/dashboardPage views: 17Page load duration: 109 ms',
'http://opbeans-node:3000/ordersPage views: 14Page load duration: 72 ms',
'http://opbeans-node:3000/dashboardTotal page views: 17Page load duration: 109 ms (median)',
'http://opbeans-node:3000/ordersTotal page views: 14Page load duration: 72 ms (median)',
];

cy.get('li.euiSelectableListItem')
Expand Down Expand Up @@ -55,7 +55,7 @@ Then(`it should filter results based on query`, () => {
listOfUrls.should('have.length', 1);

const actualUrlsText = [
'http://opbeans-node:3000/customersPage views: 10Page load duration: 76 ms',
'http://opbeans-node:3000/customersTotal page views: 10Page load duration: 76 ms (median)',
];

cy.get('li.euiSelectableListItem')
Expand Down
615 changes: 366 additions & 249 deletions x-pack/plugins/apm/e2e/yarn.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ import { ImpactfulMetrics } from './ImpactfulMetrics';
import { PageLoadAndViews } from './Panels/PageLoadAndViews';
import { VisitorBreakdownsPanel } from './Panels/VisitorBreakdowns';
import { useBreakPoints } from './hooks/useBreakPoints';
import { getPercentileLabel } from './UXMetrics/translations';
import { useUrlParams } from '../../../hooks/useUrlParams';

export function RumDashboard() {
const {
urlParams: { percentile },
} = useUrlParams();
const { isSmall } = useBreakPoints();

return (
Expand All @@ -30,7 +35,10 @@ export function RumDashboard() {
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={1} data-cy={`client-metrics`}>
<EuiTitle size="xs">
<h3>{I18LABELS.pageLoadDuration}</h3>
<h3>
{I18LABELS.pageLoadDuration} (
{getPercentileLabel(percentile!)})
</h3>
</EuiTitle>
<EuiSpacer size="s" />
<ClientMetrics />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function RumHome() {
wrap
style={{ flexWrap: 'wrap-reverse' }}
justifyContent="flexEnd"
gutterSize="s"
>
<MainFilters />
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { formatToSec } from '../../UXMetrics/KeyUXMetrics';
import { SelectableUrlList } from './SelectableUrlList';
import { UrlOption } from './RenderOption';
import { useUxQuery } from '../../hooks/useUxQuery';
import { getPercentileLabel } from '../../UXMetrics/translations';

interface Props {
onChange: (value: string[]) => void;
Expand All @@ -26,7 +27,7 @@ export function URLSearch({ onChange: onFilterChange }: Props) {

const { uiFilters, urlParams } = useUrlParams();

const { searchTerm } = urlParams;
const { searchTerm, percentile } = urlParams;

const [popoverIsOpen, setPopoverIsOpen] = useState(false);

Expand Down Expand Up @@ -104,12 +105,17 @@ export function URLSearch({ onChange: onFilterChange }: Props) {
setCheckedUrls(clickedItems.map((item) => item.url));
};

const percTitle = getPercentileLabel(percentile!);

const items: UrlOption[] = (data?.items ?? []).map((item) => ({
label: item.url,
key: item.url,
meta: [
I18LABELS.pageViews + ': ' + item.count,
I18LABELS.pageLoadDuration + ': ' + formatToSec(item.pld),
I18LABELS.pageLoadDuration +
': ' +
formatToSec(item.pld) +
` (${percTitle})`,
],
url: item.url,
checked: checkedUrls?.includes(item.url) ? 'on' : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ import { KeyUXMetrics } from './KeyUXMetrics';
import { useFetcher } from '../../../../hooks/useFetcher';
import { useUxQuery } from '../hooks/useUxQuery';
import { CoreVitals } from '../../../../../../observability/public';
import { useUrlParams } from '../../../../hooks/useUrlParams';
import { getPercentileLabel } from './translations';

export function UXMetrics() {
const {
urlParams: { percentile },
} = useUrlParams();

const uxQuery = useUxQuery();

const { data, status } = useFetcher(
Expand All @@ -41,8 +47,10 @@ export function UXMetrics() {
<EuiPanel>
<EuiFlexGroup justifyContent="spaceBetween" wrap>
<EuiFlexItem grow={1} data-cy={`client-metrics`}>
<EuiTitle size="s">
<h2>{I18LABELS.userExperienceMetrics}</h2>
<EuiTitle size="xs">
<h3>
{I18LABELS.metrics} ({getPercentileLabel(percentile!)})
</h3>
</EuiTitle>
<EuiSpacer size="s" />
<KeyUXMetrics data={data} loading={status !== 'success'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import { I18LABELS } from '../translations';

export const DATA_UNDEFINED_LABEL = i18n.translate(
'xpack.apm.rum.coreVitals.dataUndefined',
Expand Down Expand Up @@ -41,3 +42,14 @@ export const SUM_LONG_TASKS = i18n.translate(
defaultMessage: 'Total long tasks duration',
}
);

export const getPercentileLabel = (value: number) => {
if (value === 50) return I18LABELS.median;

return i18n.translate('xpack.apm.ux.percentiles.label', {
defaultMessage: '{value}th Perc.',
values: {
value,
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const I18LABELS = {
defaultMessage: 'Frontend',
}),
pageViews: i18n.translate('xpack.apm.rum.dashboard.pageViews', {
defaultMessage: 'Page views',
defaultMessage: 'Total page views',
}),
percPageLoaded: i18n.translate('xpack.apm.rum.dashboard.pagesLoaded.label', {
defaultMessage: 'Pages loaded',
Expand Down Expand Up @@ -79,8 +79,11 @@ export const I18LABELS = {
defaultMessage: 'Operating system',
}
),
userExperienceMetrics: i18n.translate('xpack.apm.rum.userExperienceMetrics', {
defaultMessage: 'User experience metrics',
metrics: i18n.translate('xpack.apm.ux.metrics', {
defaultMessage: 'Metrics',
}),
median: i18n.translate('xpack.apm.ux.median', {
defaultMessage: 'median',
}),
avgPageLoadDuration: i18n.translate(
'xpack.apm.rum.visitorBreakdownMap.avgPageLoadDuration',
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -5043,7 +5043,6 @@
"xpack.apm.rum.jsErrors.errorRateValue": "{errorRate} %",
"xpack.apm.rum.jsErrors.impactedPageLoads": "影響を受けるページ読み込み数",
"xpack.apm.rum.jsErrors.totalErrors": "合計エラー数",
"xpack.apm.rum.userExperienceMetrics": "ユーザーエクスペリエンスメトリック",
"xpack.apm.rum.uxMetrics.longestLongTasks": "最長タスク時間",
"xpack.apm.rum.uxMetrics.noOfLongTasks": "時間がかかるタスク数",
"xpack.apm.rum.uxMetrics.sumLongTasks": "時間がかかるタスクの合計時間",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -5047,7 +5047,6 @@
"xpack.apm.rum.jsErrors.errorRateValue": "{errorRate}%",
"xpack.apm.rum.jsErrors.impactedPageLoads": "受影响的页面加载",
"xpack.apm.rum.jsErrors.totalErrors": "错误总数",
"xpack.apm.rum.userExperienceMetrics": "用户体验指标",
"xpack.apm.rum.uxMetrics.longestLongTasks": "长期任务最长持续时间",
"xpack.apm.rum.uxMetrics.noOfLongTasks": "长期任务数目",
"xpack.apm.rum.uxMetrics.sumLongTasks": "长期任务总持续时间",
Expand Down

0 comments on commit e3f9649

Please sign in to comment.