Skip to content

Commit a395952

Browse files
authored
[User experience] Fix JS error rate (#81512) (#81888)
* Query adjustments for getClientMetrics * Remove error rate from JS errors section
1 parent 542423a commit a395952

File tree

8 files changed

+68
-95
lines changed

8 files changed

+68
-95
lines changed

x-pack/plugins/apm/e2e/cypress/support/step_definitions/csm/js_errors.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ Then(`it displays list of relevant js errors`, () => {
1212
cy.get('.euiBasicTable-loading').should('not.be.visible');
1313
cy.get('.euiStat__title-isLoading').should('not.be.visible');
1414

15-
getDataTestSubj('uxJsErrorsTotal').should('have.text', 'Total errors110');
16-
17-
getDataTestSubj('uxJsErrorRate').should(
18-
'have.text',
19-
'Error rate100 %Error rate 100 %'
20-
);
15+
getDataTestSubj('uxJsErrorsTotal').should('have.text', 'Total errors112');
2116

2217
getDataTestSubj('uxJsErrorTable').within(() => {
2318
cy.get('tr.euiTableRow', DEFAULT_TIMEOUT)

x-pack/plugins/apm/public/components/app/RumDashboard/ImpactfulMetrics/JSErrors.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
EuiToolTip,
1616
} from '@elastic/eui';
1717
import numeral from '@elastic/numeral';
18-
import { i18n } from '@kbn/i18n';
1918
import { FormattedMessage } from '@kbn/i18n/react';
2019
import { useUrlParams } from '../../../../hooks/useUrlParams';
2120
import { useFetcher } from '../../../../hooks/useFetcher';
@@ -102,11 +101,6 @@ export function JSErrors() {
102101
});
103102
};
104103

105-
const errorRate =
106-
totalPageViews > 0
107-
? ((data?.totalErrorPages ?? 0) / totalPageViews) * 100
108-
: 0;
109-
110104
const totalErrors = data?.totalErrors ?? 0;
111105

112106
return (
@@ -133,20 +127,6 @@ export function JSErrors() {
133127
isLoading={status !== 'success'}
134128
/>
135129
</EuiFlexItem>
136-
<EuiFlexItem grow={false}>
137-
<EuiStat
138-
data-test-subj={'uxJsErrorRate'}
139-
titleSize="s"
140-
title={i18n.translate('xpack.apm.rum.jsErrors.errorRateValue', {
141-
defaultMessage: '{errorRate} %',
142-
values: {
143-
errorRate: errorRate.toFixed(0),
144-
},
145-
})}
146-
description={I18LABELS.errorRate}
147-
isLoading={status !== 'success'}
148-
/>
149-
</EuiFlexItem>{' '}
150130
</EuiFlexGroup>
151131
<EuiSpacer size="s" />
152132
<EuiBasicTable

x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap

Lines changed: 27 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugins/apm/server/lib/rum_client/get_client_metrics.ts

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { TRANSACTION_DURATION } from '../../../common/elasticsearch_fieldnames';
87
import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions';
98
import { mergeProjection } from '../../projections/util/merge_projection';
109
import { Setup, SetupTimeRange } from '../helpers/setup_request';
@@ -25,32 +24,36 @@ export async function getClientMetrics({
2524
const projection = getRumPageLoadTransactionsProjection({
2625
setup,
2726
urlQuery,
27+
checkFetchStartFieldExists: false,
2828
});
2929

3030
const params = mergeProjection(projection, {
3131
body: {
3232
size: 0,
33+
track_total_hits: true,
3334
aggs: {
34-
pageViews: {
35-
value_count: {
36-
field: TRANSACTION_DURATION,
35+
hasFetchStartField: {
36+
filter: {
37+
exists: { field: 'transaction.marks.navigationTiming.fetchStart' },
3738
},
38-
},
39-
backEnd: {
40-
percentiles: {
41-
field: TRANSACTION_TIME_TO_FIRST_BYTE,
42-
percents: [percentile],
43-
hdr: {
44-
number_of_significant_value_digits: 3,
39+
aggs: {
40+
backEnd: {
41+
percentiles: {
42+
field: TRANSACTION_TIME_TO_FIRST_BYTE,
43+
percents: [percentile],
44+
hdr: {
45+
number_of_significant_value_digits: 3,
46+
},
47+
},
4548
},
46-
},
47-
},
48-
domInteractive: {
49-
percentiles: {
50-
field: TRANSACTION_DOM_INTERACTIVE,
51-
percents: [percentile],
52-
hdr: {
53-
number_of_significant_value_digits: 3,
49+
domInteractive: {
50+
percentiles: {
51+
field: TRANSACTION_DOM_INTERACTIVE,
52+
percents: [percentile],
53+
hdr: {
54+
number_of_significant_value_digits: 3,
55+
},
56+
},
5457
},
5558
},
5659
},
@@ -59,15 +62,16 @@ export async function getClientMetrics({
5962
});
6063

6164
const { apmEventClient } = setup;
62-
6365
const response = await apmEventClient.search(params);
64-
const { backEnd, domInteractive, pageViews } = response.aggregations!;
66+
const {
67+
hasFetchStartField: { backEnd, domInteractive },
68+
} = response.aggregations!;
6569

6670
const pkey = percentile.toFixed(1);
6771

6872
// Divide by 1000 to convert ms into seconds
6973
return {
70-
pageViews,
74+
pageViews: { value: response.hits.total.value ?? 0 },
7175
backEnd: { value: backEnd.values[pkey] || 0 },
7276
frontEnd: {
7377
value: (domInteractive.values[pkey] || 0) - (backEnd.values[pkey] || 0),

x-pack/plugins/apm/server/lib/rum_client/get_page_view_trends.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export async function getPageViewTrends({
2020
const projection = getRumPageLoadTransactionsProjection({
2121
setup,
2222
urlQuery,
23+
checkFetchStartFieldExists: false,
2324
});
2425
let breakdownItem: BreakdownItem | null = null;
2526
if (breakdowns) {

x-pack/plugins/apm/server/projections/rum_page_load_transactions.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,29 @@ import { TRANSACTION_PAGE_LOAD } from '../../common/transaction_types';
1717
export function getRumPageLoadTransactionsProjection({
1818
setup,
1919
urlQuery,
20+
checkFetchStartFieldExists = true,
2021
}: {
2122
setup: Setup & SetupTimeRange;
2223
urlQuery?: string;
24+
checkFetchStartFieldExists?: boolean;
2325
}) {
2426
const { start, end, esFilter } = setup;
2527

2628
const bool = {
2729
filter: [
2830
{ range: rangeFilter(start, end) },
2931
{ term: { [TRANSACTION_TYPE]: TRANSACTION_PAGE_LOAD } },
30-
{
31-
// Adding this filter to cater for some inconsistent rum data
32-
// not available on aggregated transactions
33-
exists: {
34-
field: 'transaction.marks.navigationTiming.fetchStart',
35-
},
36-
},
32+
...(checkFetchStartFieldExists
33+
? [
34+
{
35+
// Adding this filter to cater for some inconsistent rum data
36+
// not available on aggregated transactions
37+
exists: {
38+
field: 'transaction.marks.navigationTiming.fetchStart',
39+
},
40+
},
41+
]
42+
: []),
3743
...(urlQuery
3844
? [
3945
{
@@ -74,7 +80,6 @@ export function getRumErrorsProjection({
7480
filter: [
7581
{ range: rangeFilter(start, end) },
7682
{ term: { [AGENT_NAME]: 'rum-js' } },
77-
{ term: { [TRANSACTION_TYPE]: TRANSACTION_PAGE_LOAD } },
7883
{
7984
term: {
8085
[SERVICE_LANGUAGE_NAME]: 'javascript',

x-pack/plugins/translations/translations/ja-JP.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5045,7 +5045,6 @@
50455045
"xpack.apm.rum.filters.url.noResults": "結果がありません",
50465046
"xpack.apm.rum.jsErrors.errorMessage": "エラーメッセージ",
50475047
"xpack.apm.rum.jsErrors.errorRate": "エラー率",
5048-
"xpack.apm.rum.jsErrors.errorRateValue": "{errorRate} %",
50495048
"xpack.apm.rum.jsErrors.impactedPageLoads": "影響を受けるページ読み込み数",
50505049
"xpack.apm.rum.jsErrors.totalErrors": "合計エラー数",
50515050
"xpack.apm.rum.userExperienceMetrics": "ユーザーエクスペリエンスメトリック",

x-pack/plugins/translations/translations/zh-CN.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5049,7 +5049,6 @@
50495049
"xpack.apm.rum.filters.url.noResults": "没有可用结果",
50505050
"xpack.apm.rum.jsErrors.errorMessage": "错误消息",
50515051
"xpack.apm.rum.jsErrors.errorRate": "错误率",
5052-
"xpack.apm.rum.jsErrors.errorRateValue": "{errorRate}%",
50535052
"xpack.apm.rum.jsErrors.impactedPageLoads": "受影响的页面加载",
50545053
"xpack.apm.rum.jsErrors.totalErrors": "错误总数",
50555054
"xpack.apm.rum.userExperienceMetrics": "用户体验指标",

0 commit comments

Comments
 (0)