Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[User experience] Fix JS error rate #81512

Merged
merged 8 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions x-pack/plugins/apm/server/lib/rum_client/get_client_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { TRANSACTION_DURATION } from '../../../common/elasticsearch_fieldnames';
import { getRumPageLoadTransactionsProjection } from '../../projections/rum_page_load_transactions';
import { mergeProjection } from '../../projections/util/merge_projection';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
Expand All @@ -25,17 +24,14 @@ export async function getClientMetrics({
const projection = getRumPageLoadTransactionsProjection({
setup,
urlQuery,
checkFetchStartFieldExists: false,
shahzad31 marked this conversation as resolved.
Show resolved Hide resolved
});

const params = mergeProjection(projection, {
body: {
size: 0,
track_total_hits: true,
aggs: {
pageViews: {
value_count: {
field: TRANSACTION_DURATION,
},
},
backEnd: {
percentiles: {
field: TRANSACTION_TIME_TO_FIRST_BYTE,
Expand All @@ -59,15 +55,14 @@ export async function getClientMetrics({
});

const { apmEventClient } = setup;

const response = await apmEventClient.search(params);
const { backEnd, domInteractive, pageViews } = response.aggregations!;
const { backEnd, domInteractive } = response.aggregations!;

const pkey = percentile.toFixed(1);

// Divide by 1000 to convert ms into seconds
return {
pageViews,
pageViews: { value: response.hits.total.value ?? 0 },
backEnd: { value: backEnd.values[pkey] || 0 },
frontEnd: {
value: (domInteractive.values[pkey] || 0) - (backEnd.values[pkey] || 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,29 @@ import { TRANSACTION_PAGE_LOAD } from '../../common/transaction_types';
export function getRumPageLoadTransactionsProjection({
setup,
urlQuery,
checkFetchStartFieldExists = true,
}: {
setup: Setup & SetupTimeRange;
urlQuery?: string;
checkFetchStartFieldExists?: boolean;
}) {
const { start, end, esFilter } = setup;

const bool = {
filter: [
{ range: rangeFilter(start, end) },
{ term: { [TRANSACTION_TYPE]: TRANSACTION_PAGE_LOAD } },
{
// Adding this filter to cater for some inconsistent rum data
// not available on aggregated transactions
exists: {
field: 'transaction.marks.navigationTiming.fetchStart',
},
},
...(checkFetchStartFieldExists
? [
{
// Adding this filter to cater for some inconsistent rum data
// not available on aggregated transactions
exists: {
field: 'transaction.marks.navigationTiming.fetchStart',
},
},
]
: []),
...(urlQuery
? [
{
Expand Down