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

[APM] Mobile crashes & errors #165892

Merged
merged 82 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
9e382fb
Mobile Errors & Crashes UI
bryce-b Aug 9, 2023
c3b5a83
improved naming of http error rate chart
bryce-b Oct 17, 2023
c935a7c
re-enabled mobile error detail page
bryce-b Oct 17, 2023
d1bb4d8
Fixing build issues
bryce-b Oct 30, 2023
03bb58a
fixed imports
bryce-b Oct 30, 2023
ed74fe7
additional fixes
bryce-b Oct 30, 2023
464d3af
additional fixes
bryce-b Oct 31, 2023
df4b779
corrected different default translations.
bryce-b Oct 31, 2023
78ae4e6
additional translation fixes
bryce-b Oct 31, 2023
4b695ff
additional text fixes
bryce-b Oct 31, 2023
a6f7894
updated jest tests for crash queries
bryce-b Oct 31, 2023
27ba5c7
fixed more jest tests
bryce-b Oct 31, 2023
8f5799c
removed obsolete jest test
bryce-b Oct 31, 2023
d63bd91
fixed transaction/view issue
bryce-b Nov 2, 2023
8ebdad3
Merge branch 'main' into mobile-errors
bryce-b Nov 2, 2023
25dafad
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 2, 2023
803abac
crash detail wip
bryce-b Nov 2, 2023
b91e83f
re-enabled dependencies tab for mobile
bryce-b Nov 3, 2023
0be8ec8
updated crash details page
bryce-b Nov 3, 2023
b054deb
removed beta badge from mobile
bryce-b Nov 3, 2023
eb7168b
Merge branch 'main' into mobile-errors
bryce-b Nov 3, 2023
9aed2e8
Merge branch 'main' into mobile-errors
bryce-b Nov 6, 2023
c7dc34f
updated docs
bryce-b Nov 6, 2023
4af66f7
Merge branch 'main' into mobile-errors
bryce-b Nov 7, 2023
1f2df28
Merge branch 'main' into mobile-errors
bryce-b Nov 7, 2023
bf5b01c
added tests for crash apis
bryce-b Nov 8, 2023
ba810ce
added jest tests for crash and error group list
bryce-b Nov 8, 2023
e6b4200
Merge branch 'main' into mobile-errors
bryce-b Nov 8, 2023
9e31704
Merge branch 'main' into mobile-errors
bryce-b Nov 9, 2023
d4d2394
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 10, 2023
23b517e
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 10, 2023
f9b9ed5
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 10, 2023
1dbdc17
fixed bad merge & added mobile session how to guide
bryce-b Nov 13, 2023
0d10f86
Merge branch 'main' into mobile-errors
bryce-b Nov 13, 2023
b079a2c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 2, 2023
3a8745c
removed unused datemath.ts & fixed tsconfig.json
bryce-b Nov 13, 2023
30f5a8f
refactored and simplified tabs
bryce-b Nov 13, 2023
756552f
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 13, 2023
a228770
removed unused module
bryce-b Nov 14, 2023
fe65a72
Merge branch 'main' into mobile-errors
bryce-b Nov 14, 2023
517f43e
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 14, 2023
7e698fa
removed unused module
bryce-b Nov 14, 2023
350015b
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 14, 2023
5aad559
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 14, 2023
a8631c3
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 14, 2023
32786a1
Update x-pack/plugins/apm/public/components/app/mobile/error_group_ov…
bryce-b Nov 14, 2023
8a5be49
renamed errors path to errors-and-crashes
bryce-b Nov 14, 2023
41686ca
additional renames
bryce-b Nov 14, 2023
4dcc9f9
use HTTP_RESPONSE_STATUS_CODE
bryce-b Nov 14, 2023
a443970
corrected http errors query
bryce-b Nov 14, 2023
561d98e
removed get_mobile_crash_terms_by_field
bryce-b Nov 15, 2023
4e9cd64
fixed filter dropdown, and overview treemaps
bryce-b Nov 16, 2023
98846ad
mobile filters applied to detail pages
bryce-b Nov 16, 2023
36300e0
mobile treemaps filter error groups
bryce-b Nov 16, 2023
bd28a6a
Merge branch 'main' into mobile-errors
bryce-b Nov 16, 2023
5cd2501
fixed crash title i18n
bryce-b Nov 16, 2023
3aa6edb
updated additional transations
bryce-b Nov 16, 2023
fea08e6
removed unused transation
bryce-b Nov 16, 2023
eca5ae7
Merge branch 'main' into mobile-errors
bryce-b Nov 16, 2023
cd33d0a
changed api name to match proper style
bryce-b Nov 20, 2023
6f6860c
Merge branch 'main' into mobile-errors
bryce-b Nov 20, 2023
07530d1
Merge branch 'main' into mobile-errors
bryce-b Nov 21, 2023
5bef0eb
Merge branch 'main' into mobile-errors
bryce-b Nov 21, 2023
5cba75a
Merge branch 'main' into mobile-errors
bryce-b Nov 21, 2023
e5e1de3
Merge branch 'main' into mobile-errors
bryce-b Nov 22, 2023
fb308bb
Update x-pack/plugins/apm/server/routes/mobile/crashes/distribution/g…
bryce-b Nov 22, 2023
c5901c8
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 22, 2023
f7b8d30
refactored mobile error tree maps
bryce-b Nov 27, 2023
9c71bb2
refactored error and crashes details page
bryce-b Nov 27, 2023
546ca8f
Merge branch 'main' into mobile-errors
bryce-b Nov 27, 2023
eebcd78
Merge branch 'main' into mobile-errors
bryce-b Nov 28, 2023
2815c65
Merge branch 'main' into mobile-errors
bryce-b Nov 29, 2023
6a84479
Merge branch 'main' into mobile-errors
bryce-b Nov 29, 2023
d781939
refactored errors detail to reused components
bryce-b Nov 29, 2023
e860014
Merge branch 'main' into mobile-errors
bryce-b Nov 29, 2023
2b4e77b
fixed i18n issues
bryce-b Nov 30, 2023
e6547fc
removed unused error_sampler
bryce-b Nov 30, 2023
8185122
corrected apm parameter path for error_sampler
bryce-b Nov 30, 2023
14b283b
error_sample_detail with crash path
bryce-b Nov 30, 2023
3e46d7f
Merge branch 'main' into mobile-errors
bryce-b Nov 30, 2023
c3e9a6f
fixed crash type link in crash overview list
bryce-b Dec 1, 2023
1672026
Merge branch 'main' into mobile-errors
bryce-b Dec 1, 2023
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
3 changes: 3 additions & 0 deletions docs/apm/how-to-guides.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Learn how to perform common APM app tasks.
* <<correlations>>
* <<agent-explorer>>
* <<machine-learning-integration>>
* <<mobile-session-explorer>>
* <<apm-lambda>>
* <<advanced-queries>>
* <<storage-explorer>>
Expand All @@ -35,6 +36,8 @@ include::agent-explorer.asciidoc[]

include::machine-learning.asciidoc[]

include::mobile-session-explorer.asciidoc[]

include::lambda.asciidoc[]

include::advanced-queries.asciidoc[]
Expand Down
Binary file added docs/apm/images/mobile-session-error-details.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/apm/images/mobile-session-explorer-apm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/apm/images/mobile-session-explorer-nav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions docs/apm/mobile-errors.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[role="xpack"]
[[mobile-errors-crashes]]
=== Mobile errors and crashes

TIP: {apm-guide-ref}/data-model-errors.html[Errors] are groups of exceptions with a similar exception or log message.

The *Errors & Crashes* overview provides a high-level view of errors and crashes that APM mobile agents catch,
or that users manually report with APM agent APIs. Errors and crashes are separated into two tabs for easy differentiation.
Like errors are grouped together to make it easy to quickly see which errors are affecting your services,
and to take actions to rectify them.





[role="screenshot"]
image::apm/images/mobile-errors-overview.png[Mobile Errors overview]

Selecting an error group ID or error message brings you to the *Error group*.

[role="screenshot"]
image::apm/images/mobile-error-group.png[Mobile Error group]

The error group details page visualizes the number of error occurrences over time and compared to a recent time range.
This allows you to quickly determine if the error rate is changing or remaining constant.
You'll also see the "most affected" chart which can be oriented to 'by device' or 'by app version'.

Further down, you'll see an Error sample.
The error shown is always the most recent to occur.
The sample includes the exception message, culprit, stack trace where the error occurred (when available),
and additional contextual information to help debug the issue--all of which can be copied with the click of a button.

In some cases, you might also see a Transaction sample ID.
This feature allows you to make a connection between the errors and transactions,
by linking you to the specific transaction where the error occurred.
This allows you to see the whole trace, including which services the request went through.
4 changes: 3 additions & 1 deletion docs/apm/mobile-service.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ to make data-driven decisions about how to improve your user experience.

For example, see:

* Crash Rate (Crashes per minute) -- coming soon
* Crash Rate (Crashes per session)
* Slowest App load time -- coming soon
* Number of sessions
* Number of HTTP requests
Expand All @@ -28,6 +28,8 @@ of their mobile application environment and the impact of backend errors and bot
Understand the impact of slow application load times and variations in application crash rate on user traffic (coming soon).
Visualize session and HTTP trends, and see where your users are located--enabling you to optimize your infrastructure deployment and routing topology.

Note: due to the way crash rate is calculated (crashes per session) it is possible to have greater than 100% rate, due to fact that a session may contain multiple crashes.

[role="screenshot"]
image::apm/images/mobile-location.png[mobile service overview centered on location map]

Expand Down
43 changes: 43 additions & 0 deletions docs/apm/mobile-session-explorer.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[role="xpack]
[[mobile-session-explorer]]
=== Exploring mobile sessions with Discover
Elastic Mobile APM provides session tracking by attaching a `session.id`, a guid, to every span and event.
This allows for the recall of the activities of a specific user during a specific period of time. The best way recall
these data points is using the xref:document-explorer[Discover document explorer]. This guide will explain how to do that.

=== Viewing sessions with Discover

The first step is to find the relevant `session.id`. In this example, we'll walk through investigating a crash.
Since all events and spans have `session.id` attributes, a crash is no different.

The steps to follow are:

* copy the `session.id` from the relevant document.
* Open the Discover page.
* Select the appropriate data view (use `APM` to search all datastreams)
* set filter to the copied `session.id`

Here we can see the `session.id` guid in the metadata viewer in the error detail view:
[role="screenshot"]
image::images/mobile-session-error-details.png[Example of session.id in error details]

Copy this value and open the Discover page:

[role="screenshot"]
image::images/mobile-session-explorer-nav.png[Example view of navigation to Discover]


set the data view. `APM` selected in the example:

[role="screenshot"]
image::images/mobile-session-explorer-apm.png[Example view of Explorer selecting APM data view]

filter using the `session.id`: `session.id: "<copied session id guid>"`:

[role="screenshot"]
image::images/mobile-session-filter-discover.png[Filter Explor using session.id]

explore all the documents associated with that session id including crashes, lifecycle events, network requests, errors, and other custom events!



8 changes: 8 additions & 0 deletions packages/kbn-apm-synthtrace-client/src/lib/apm/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ export class Instance extends Entity<ApmFields> {
});
}

crash({ message, type }: { message: string; type?: string }) {
return new ApmError({
...this.fields,
'error.type': 'crash',
'error.exception': [{ message, ...(type ? { type } : {}) }],
'error.grouping_name': getErrorGroupingKey(message),
});
}
error({ message, type }: { message: string; type?: string }) {
return new ApmError({
...this.fields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
* 2.0.
*/

import { getKueryWithMobileFilters } from './get_kuery_with_mobile_filters';
import {
getKueryWithMobileFilters,
getKueryWithMobileCrashFilter,
getKueryWithMobileErrorFilter,
} from './get_kuery_with_mobile_filters';
describe('getKueryWithMobileFilters', () => {
it('should handle empty and undefined values', () => {
const result = getKueryWithMobileFilters({
Expand Down Expand Up @@ -70,3 +74,68 @@ describe('getKueryWithMobileFilters', () => {
);
});
});

describe('getKueryWithMobileCrashFilter', () => {
it('should handle empty and undefined values', () => {
const result = getKueryWithMobileCrashFilter({
groupId: undefined,
kuery: '',
});
expect(result).toBe('error.type: crash');
});
it('should return kuery and crash filter when groupId is empty', () => {
const result = getKueryWithMobileCrashFilter({
groupId: undefined,
kuery: 'foo.bar: test',
});
expect(result).toBe('foo.bar: test and error.type: crash');
});
it('should return crash filter and groupId when kuery is empty', () => {
const result = getKueryWithMobileCrashFilter({
groupId: '1',
kuery: '',
});
expect(result).toBe('error.type: crash and error.grouping_key: 1');
});
it('should return crash filter, groupId, and kuery in kql format', () => {
const result = getKueryWithMobileCrashFilter({
groupId: '1',
kuery: 'foo.bar: test',
});
expect(result).toBe(
'foo.bar: test and error.type: crash and error.grouping_key: 1'
);
});
});
describe('getKueryWithMobileErrorFilter', () => {
it('should handle empty and undefined values', () => {
const result = getKueryWithMobileErrorFilter({
groupId: undefined,
kuery: '',
});
expect(result).toBe('NOT error.type: crash');
});
it('should return kuery and error filter when groupId is empty', () => {
const result = getKueryWithMobileErrorFilter({
kuery: 'foo.bar: test',
groupId: undefined,
});
expect(result).toBe('foo.bar: test and NOT error.type: crash');
});
it('should return error filter and groupId when kuery is empty', () => {
const result = getKueryWithMobileErrorFilter({
groupId: '1',
kuery: '',
});
expect(result).toBe('NOT error.type: crash and error.grouping_key: 1');
});
it('should return error filter, groupId, and kuery in kql format', () => {
const result = getKueryWithMobileErrorFilter({
groupId: '1',
kuery: 'foo.bar: test',
});
expect(result).toBe(
'foo.bar: test and NOT error.type: crash and error.grouping_key: 1'
);
});
});
36 changes: 36 additions & 0 deletions x-pack/plugins/apm/common/utils/get_kuery_with_mobile_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
DEVICE_MODEL_IDENTIFIER,
NETWORK_CONNECTION_TYPE,
SERVICE_VERSION,
ERROR_TYPE,
ERROR_GROUP_ID,
} from '../es_fields/apm';
import { fieldValuePairToKql } from './field_value_pair_to_kql';

Expand Down Expand Up @@ -38,3 +40,37 @@ export function getKueryWithMobileFilters({

return kueryWithFilters;
}

export function getKueryWithMobileCrashFilter({
groupId,
kuery,
}: {
groupId: string | undefined;
kuery: string;
}) {
const kueryWithFilters = [
kuery,
...fieldValuePairToKql(ERROR_TYPE, 'crash'),
...fieldValuePairToKql(ERROR_GROUP_ID, groupId),
]
.filter(Boolean)
.join(' and ');
return kueryWithFilters;
}

export function getKueryWithMobileErrorFilter({
groupId,
kuery,
}: {
groupId: string | undefined;
kuery: string;
}) {
const kueryWithFilters = [
kuery,
`NOT ${ERROR_TYPE}: crash`,
...fieldValuePairToKql(ERROR_GROUP_ID, groupId),
]
.filter(Boolean)
.join(' and ');
return kueryWithFilters;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { TraceSearchType } from '../../../../../common/trace_explorer';
import { APMError } from '../../../../../typings/es_schemas/ui/apm_error';
import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context';
import { useLegacyUrlParams } from '../../../../context/url_params_context/use_url_params';
import { useApmParams } from '../../../../hooks/use_apm_params';
import { useAnyOfApmParams } from '../../../../hooks/use_apm_params';
import { useApmRouter } from '../../../../hooks/use_apm_router';
import { FETCH_STATUS, isPending } from '../../../../hooks/use_fetcher';
import { useTraceExplorerEnabledSetting } from '../../../../hooks/use_trace_explorer_enabled_setting';
Expand Down Expand Up @@ -102,7 +102,10 @@ export function ErrorSampleDetails({
const {
path: { groupId },
query,
} = useApmParams('/services/{serviceName}/errors/{groupId}');
} = useAnyOfApmParams(
'/services/{serviceName}/errors/{groupId}',
'/mobile-services/{serviceName}/errors-and-crashes/errors/{groupId}'
);

const { kuery } = query;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EuiLoadingSpinner } from '@elastic/eui';
import React from 'react';
import { useHistory } from 'react-router-dom';
import { fromQuery, toQuery } from '../../../shared/links/url_helpers';
import { useApmParams } from '../../../../hooks/use_apm_params';
import { useAnyOfApmParams } from '../../../../hooks/use_apm_params';
import {
FETCH_STATUS,
isPending,
Expand Down Expand Up @@ -36,7 +36,10 @@ export function ErrorSampler({
const {
path: { groupId },
query,
} = useApmParams('/services/{serviceName}/errors/{groupId}');
} = useAnyOfApmParams(
'/services/{serviceName}/errors/{groupId}',
'/mobile-services/{serviceName}/errors-and-crashes/errors/{groupId}'
);

const { rangeFrom, rangeTo, environment, kuery, errorId } = query;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React, { useState } from 'react';
import { EuiSpacer } from '@elastic/eui';
import { TreemapSelect, TreemapTypes } from './treemap_select';
import { TreemapChart } from '../../../../shared/charts/treemap_chart';
import { useFetcher } from '../../../../../hooks/use_fetcher';
import {
DEVICE_MODEL_IDENTIFIER,
SERVICE_VERSION,
} from '../../../../../../common/es_fields/apm';

const ES_FIELD_MAPPING: Record<TreemapTypes, string> = {
[TreemapTypes.Devices]: DEVICE_MODEL_IDENTIFIER,
[TreemapTypes.Versions]: SERVICE_VERSION,
};

export function MobileErrorsAndCrashesTreemap({
kuery,
serviceName,
start,
end,
environment,
}: {
kuery: string;
serviceName: string;
start: string;
end: string;
environment: string;
}) {
const [selectedTreemap, selectTreemap] = useState(TreemapTypes.Devices);

const { data, status } = useFetcher(
(callApmApi) => {
const fieldName = ES_FIELD_MAPPING[selectedTreemap];
if (fieldName) {
return callApmApi(
'GET /internal/apm/mobile-services/{serviceName}/error_terms',
{
params: {
path: {
serviceName,
},
query: {
environment,
kuery,
start,
end,
fieldName,
size: 500,
},
},
}
);
}
},
[environment, kuery, serviceName, start, end, selectedTreemap]
);
return (
<>
<TreemapSelect
selectedTreemap={selectedTreemap}
onChange={selectTreemap}
/>
<EuiSpacer size="s" />
<TreemapChart
fetchStatus={status}
data={data?.terms ?? []}
id="device-treemap"
height={320}
/>
</>
);
}
Loading