Skip to content

Conversation

@maryam-saeidi
Copy link
Member

@maryam-saeidi maryam-saeidi commented Apr 11, 2025

Closes https://github.com/elastic/observability-dev/issues/4022

Summary

In this PR, we are capturing toast errors using apm-rum:

label.errorType: ToastError
Screen.Recording.2025-04-14.at.12.23.53.mov

ErrorType is available in labels which this feature was added to the rum agent in this PR.

🧪 How to test

Add the following to your kibana.yml file:

elastic.apm.active: true
elastic.apm.transactionSampleRate: 1.0
elastic.apm.environment: yourName <-- Change to your name
Throw a toast error

Add this code to a page as alerts page and visit http://localhost:5601/kibana/app/observability/alerts

useEffect(() => {
    const error = new Error('Mary test error > toasts.addError');
    toasts.addError(error, { title: 'Testing error toast', toastMessage: error.message });
    toasts.addDanger('Testing danger toast');
  }, []);

Then visit kibana-cloud-apm.elastic.dev filtered for yourName in the environment.

@maryam-saeidi maryam-saeidi self-assigned this Apr 11, 2025
@maryam-saeidi maryam-saeidi added backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Apr 11, 2025
@maryam-saeidi maryam-saeidi added backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.0.1 and removed backport:skip This PR does not require backporting labels Apr 14, 2025
@maryam-saeidi maryam-saeidi marked this pull request as ready for review April 14, 2025 10:33
@maryam-saeidi maryam-saeidi requested a review from a team as a code owner April 14, 2025 10:33
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
core 433.2KB 433.5KB +254.0B

History

cc @maryam-saeidi

Copy link
Contributor

@kpatticha kpatticha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for adding this.

I noticed that some applications use notifications.toasts.danger — for example, APM does here.

Thankfully, it's not used in many places, so I'm wondering — should we also capture errors in those cases, or should we agree on a single, consistent way to display error toasts?

@maryam-saeidi
Copy link
Member Author

should we also capture errors in those cases, or should we agree on a single, consistent way to display error toasts?

@kpatticha Do you mean making it clear when to use danger vs error toasts? (i.e., not using danger in case of an error)

@maryam-saeidi maryam-saeidi merged commit ae9e5d6 into elastic:main Apr 15, 2025
12 checks passed
@maryam-saeidi maryam-saeidi deleted the observability-dev-402-toast-error branch April 15, 2025 07:49
@kpatticha
Copy link
Contributor

should we also capture errors in those cases, or should we agree on a single, consistent way to display error toasts?

@kpatticha Do you mean making it clear when to use danger vs error toasts? (i.e., not using danger in case of an error)

There are currently two ways to display toast messages in Kibana:

  1. using the Kibana React notification service

    export interface KibanaReactNotifications {
    toasts: {
    show: (input: ToastInput) => void;
    success: (input: ToastInput) => void;
    warning: (input: ToastInput) => void;
    danger: (input: ToastInput) => void;

  2. using notification service in the core package

    export interface IToasts {
    get$: () => Observable<Toast[]>;
    add: (toastOrTitle: ToastInput) => Toast;
    remove: (toastOrId: Toast | string) => void;
    addInfo: (toastOrTitle: ToastInput, options?: any) => Toast;
    addSuccess: (toastOrTitle: ToastInput, options?: any) => Toast;
    addWarning: (toastOrTitle: ToastInput, options?: any) => Toast;
    addDanger: (toastOrTitle: ToastInput, options?: any) => Toast;
    addError: (error: Error, options: ErrorToastOptions) => Toast;

It seems Infra and APM codebase still uses in some places the first approach. As a result, error messages shown this way won't be captured using apm-rum.

I'm not sure why these apps are still using the first approach, or why both methods for showing toasts still exist—it might just be legacy code.?

Would it make sense to create a ticket to align on a single, consistent approach?

@maryam-saeidi
Copy link
Member Author

Would it make sense to create a ticket to align on a single, consistent approach?

YES! Here is the ticket: https://github.com/elastic/observability-dev/issues/4456

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 16, 2025
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create automatically backports add a backport:* label or prevent reminders by adding the backport:skip label.
You can also create backports manually by running node scripts/backport --pr 217948 locally

@maryam-saeidi
Copy link
Member Author

💚 All backports created successfully

Status Branch Result
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

maryam-saeidi added a commit that referenced this pull request Apr 17, 2025
# Backport

This will backport the following commits from `main` to `8.19`:
- [Track toast errors using apm-rum
(#217948)](#217948)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-15T07:49:11Z","message":"Track
toast errors using apm-rum (#217948)\n\nCloses
https://github.com/elastic/observability-dev/issues/4022\n\n##
Summary\n\nIn this PR, we are capturing toast errors using
apm-rum:\n\n\nhttps://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385\n\n\nErrorType
is available in labels which this feature was added to the rum\nagent in
this\n[PR](https://github.com/elastic/apm-agent-rum-js/pull/1594).\n\n\n###
🧪 How to test\n\nAdd the following to your kibana.yml
file:\n\n```\nelastic.apm.active:
true\nelastic.apm.transactionSampleRate: 1.0\nelastic.apm.environment:
yourName <-- Change to your name\n```\n<details>\n<summary>Throw a toast
error</summary>\n\nAdd this code to a page as
[alerts\npage](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)\nand
visit
http://localhost:5601/kibana/app/observability/alerts\n\n```\nuseEffect(()
=> {\n const error = new Error('Mary test error > toasts.addError');\n
toasts.addError(error, { title: 'Testing error toast', toastMessage:
error.message });\n toasts.addDanger('Testing danger toast');\n },
[]);\n```\n\n</details>\n\nThen
visit\n[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)\nfiltered
for `yourName` in the
environment.","sha":"ae9e5d679ce1ace883ec7bae432b46f9c77f2758","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport
missing","backport:version","v9.1.0","v8.19.0","v9.0.1 backport
needed"],"title":"Track toast errors using
apm-rum","number":217948,"url":"https://github.com/elastic/kibana/pull/217948","mergeCommit":{"message":"Track
toast errors using apm-rum (#217948)\n\nCloses
https://github.com/elastic/observability-dev/issues/4022\n\n##
Summary\n\nIn this PR, we are capturing toast errors using
apm-rum:\n\n\nhttps://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385\n\n\nErrorType
is available in labels which this feature was added to the rum\nagent in
this\n[PR](https://github.com/elastic/apm-agent-rum-js/pull/1594).\n\n\n###
🧪 How to test\n\nAdd the following to your kibana.yml
file:\n\n```\nelastic.apm.active:
true\nelastic.apm.transactionSampleRate: 1.0\nelastic.apm.environment:
yourName <-- Change to your name\n```\n<details>\n<summary>Throw a toast
error</summary>\n\nAdd this code to a page as
[alerts\npage](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)\nand
visit
http://localhost:5601/kibana/app/observability/alerts\n\n```\nuseEffect(()
=> {\n const error = new Error('Mary test error > toasts.addError');\n
toasts.addError(error, { title: 'Testing error toast', toastMessage:
error.message });\n toasts.addDanger('Testing danger toast');\n },
[]);\n```\n\n</details>\n\nThen
visit\n[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)\nfiltered
for `yourName` in the
environment.","sha":"ae9e5d679ce1ace883ec7bae432b46f9c77f2758"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217948","number":217948,"mergeCommit":{"message":"Track
toast errors using apm-rum (#217948)\n\nCloses
https://github.com/elastic/observability-dev/issues/4022\n\n##
Summary\n\nIn this PR, we are capturing toast errors using
apm-rum:\n\n\nhttps://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385\n\n\nErrorType
is available in labels which this feature was added to the rum\nagent in
this\n[PR](https://github.com/elastic/apm-agent-rum-js/pull/1594).\n\n\n###
🧪 How to test\n\nAdd the following to your kibana.yml
file:\n\n```\nelastic.apm.active:
true\nelastic.apm.transactionSampleRate: 1.0\nelastic.apm.environment:
yourName <-- Change to your name\n```\n<details>\n<summary>Throw a toast
error</summary>\n\nAdd this code to a page as
[alerts\npage](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)\nand
visit
http://localhost:5601/kibana/app/observability/alerts\n\n```\nuseEffect(()
=> {\n const error = new Error('Mary test error > toasts.addError');\n
toasts.addError(error, { title: 'Testing error toast', toastMessage:
error.message });\n toasts.addDanger('Testing danger toast');\n },
[]);\n```\n\n</details>\n\nThen
visit\n[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)\nfiltered
for `yourName` in the
environment.","sha":"ae9e5d679ce1ace883ec7bae432b46f9c77f2758"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 17, 2025
@maryam-saeidi
Copy link
Member Author

💚 All backports created successfully

Status Branch Result
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

maryam-saeidi added a commit to maryam-saeidi/kibana that referenced this pull request Apr 17, 2025
Closes elastic/observability-dev#4022

## Summary

In this PR, we are capturing toast errors using apm-rum:

https://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385

ErrorType is available in labels which this feature was added to the rum
agent in this
[PR](elastic/apm-agent-rum-js#1594).

### 🧪 How to test

Add the following to your kibana.yml file:

```
elastic.apm.active: true
elastic.apm.transactionSampleRate: 1.0
elastic.apm.environment: yourName <-- Change to your name
```
<details>
<summary>Throw a toast error</summary>

Add this code to a page as [alerts
page](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)
and visit http://localhost:5601/kibana/app/observability/alerts

```
useEffect(() => {
    const error = new Error('Mary test error > toasts.addError');
    toasts.addError(error, { title: 'Testing error toast', toastMessage: error.message });
    toasts.addDanger('Testing danger toast');
  }, []);
```

</details>

Then visit
[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)
filtered for `yourName` in the environment.

(cherry picked from commit ae9e5d6)

# Conflicts:
#	src/core/packages/notifications/browser-internal/src/toasts/toasts_api.tsx
maryam-saeidi added a commit that referenced this pull request Apr 17, 2025
# Backport

This will backport the following commits from `main` to `9.0`:
- [Track toast errors using apm-rum
(#217948)](#217948)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-04-15T07:49:11Z","message":"Track
toast errors using apm-rum (#217948)\n\nCloses
https://github.com/elastic/observability-dev/issues/4022\n\n##
Summary\n\nIn this PR, we are capturing toast errors using
apm-rum:\n\n\nhttps://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385\n\n\nErrorType
is available in labels which this feature was added to the rum\nagent in
this\n[PR](https://github.com/elastic/apm-agent-rum-js/pull/1594).\n\n\n###
🧪 How to test\n\nAdd the following to your kibana.yml
file:\n\n```\nelastic.apm.active:
true\nelastic.apm.transactionSampleRate: 1.0\nelastic.apm.environment:
yourName <-- Change to your name\n```\n<details>\n<summary>Throw a toast
error</summary>\n\nAdd this code to a page as
[alerts\npage](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)\nand
visit
http://localhost:5601/kibana/app/observability/alerts\n\n```\nuseEffect(()
=> {\n const error = new Error('Mary test error > toasts.addError');\n
toasts.addError(error, { title: 'Testing error toast', toastMessage:
error.message });\n toasts.addDanger('Testing danger toast');\n },
[]);\n```\n\n</details>\n\nThen
visit\n[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)\nfiltered
for `yourName` in the
environment.","sha":"ae9e5d679ce1ace883ec7bae432b46f9c77f2758","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v9.1.0","v8.19.0","v9.0.1"],"title":"Track
toast errors using
apm-rum","number":217948,"url":"https://github.com/elastic/kibana/pull/217948","mergeCommit":{"message":"Track
toast errors using apm-rum (#217948)\n\nCloses
https://github.com/elastic/observability-dev/issues/4022\n\n##
Summary\n\nIn this PR, we are capturing toast errors using
apm-rum:\n\n\nhttps://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385\n\n\nErrorType
is available in labels which this feature was added to the rum\nagent in
this\n[PR](https://github.com/elastic/apm-agent-rum-js/pull/1594).\n\n\n###
🧪 How to test\n\nAdd the following to your kibana.yml
file:\n\n```\nelastic.apm.active:
true\nelastic.apm.transactionSampleRate: 1.0\nelastic.apm.environment:
yourName <-- Change to your name\n```\n<details>\n<summary>Throw a toast
error</summary>\n\nAdd this code to a page as
[alerts\npage](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)\nand
visit
http://localhost:5601/kibana/app/observability/alerts\n\n```\nuseEffect(()
=> {\n const error = new Error('Mary test error > toasts.addError');\n
toasts.addError(error, { title: 'Testing error toast', toastMessage:
error.message });\n toasts.addDanger('Testing danger toast');\n },
[]);\n```\n\n</details>\n\nThen
visit\n[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)\nfiltered
for `yourName` in the
environment.","sha":"ae9e5d679ce1ace883ec7bae432b46f9c77f2758"}},"sourceBranch":"main","suggestedTargetBranches":["9.0"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217948","number":217948,"mergeCommit":{"message":"Track
toast errors using apm-rum (#217948)\n\nCloses
https://github.com/elastic/observability-dev/issues/4022\n\n##
Summary\n\nIn this PR, we are capturing toast errors using
apm-rum:\n\n\nhttps://github.com/user-attachments/assets/b61529f9-ab8e-4171-9042-0884e11eb385\n\n\nErrorType
is available in labels which this feature was added to the rum\nagent in
this\n[PR](https://github.com/elastic/apm-agent-rum-js/pull/1594).\n\n\n###
🧪 How to test\n\nAdd the following to your kibana.yml
file:\n\n```\nelastic.apm.active:
true\nelastic.apm.transactionSampleRate: 1.0\nelastic.apm.environment:
yourName <-- Change to your name\n```\n<details>\n<summary>Throw a toast
error</summary>\n\nAdd this code to a page as
[alerts\npage](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)\nand
visit
http://localhost:5601/kibana/app/observability/alerts\n\n```\nuseEffect(()
=> {\n const error = new Error('Mary test error > toasts.addError');\n
toasts.addError(error, { title: 'Testing error toast', toastMessage:
error.message });\n toasts.addDanger('Testing danger toast');\n },
[]);\n```\n\n</details>\n\nThen
visit\n[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)\nfiltered
for `yourName` in the
environment.","sha":"ae9e5d679ce1ace883ec7bae432b46f9c77f2758"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"url":"https://github.com/elastic/kibana/pull/218531","number":218531,"branch":"8.19","state":"MERGED","mergeCommit":{"sha":"caa2fbb25501b65fa704c8f9cf2821cc4e18ea34","message":"[8.19]
Track toast errors using apm-rum (#217948) (#218531)\n\n#
Backport\n\nThis will backport the following commits from `main` to
`8.19`:\n- [Track toast errors using
apm-rum\n(#217948)](https://github.com/elastic/kibana/pull/217948)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}}]}]
BACKPORT-->
maryam-saeidi added a commit that referenced this pull request Apr 29, 2025
Closes elastic/observability-dev#4463

## Summary

Since we now have support for error labels in RUM
([PR](elastic/apm-agent-rum-js#1594)), this PR
changes the way that we report rum errors to use labels similar to what
we've done for toast errors
([PR](#217948)).



https://github.com/user-attachments/assets/87a06ceb-705c-4c6e-ab26-d3e5874fe5ad


### ⚠️ Note

In local development, the error is captured twice because react bubbles
up the error, but it does not happen in production:
([doc](https://react.dev/reference/react/Component#componentdidcatch-caveats))

> Production and development builds of React slightly differ in the way
componentDidCatch handles errors. In development, the errors will bubble
up to window, which means that any window.onerror or
window.addEventListener('error', callback) will intercept the errors
that have been caught by componentDidCatch. In production, instead, the
errors will not bubble up, which means any ancestor error handler will
only receive errors not explicitly caught by componentDidCatch.

### 🧪 How to test

Add the following to your kibana.yml file:

```
elastic.apm.active: true
elastic.apm.transactionSampleRate: 1.0
elastic.apm.environment: yourName <-- Change to your name
```
<details>
<summary>Throw a fatal react error</summary>

Throw an error in the [alerts
page](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)
and visit http://localhost:5601/kibana/app/observability/alerts

</details>

Then visit
[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)
filtered for `yourName` in the environment.
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
Closes elastic/observability-dev#4463

## Summary

Since we now have support for error labels in RUM
([PR](elastic/apm-agent-rum-js#1594)), this PR
changes the way that we report rum errors to use labels similar to what
we've done for toast errors
([PR](elastic#217948)).



https://github.com/user-attachments/assets/87a06ceb-705c-4c6e-ab26-d3e5874fe5ad


### ⚠️ Note

In local development, the error is captured twice because react bubbles
up the error, but it does not happen in production:
([doc](https://react.dev/reference/react/Component#componentdidcatch-caveats))

> Production and development builds of React slightly differ in the way
componentDidCatch handles errors. In development, the errors will bubble
up to window, which means that any window.onerror or
window.addEventListener('error', callback) will intercept the errors
that have been caught by componentDidCatch. In production, instead, the
errors will not bubble up, which means any ancestor error handler will
only receive errors not explicitly caught by componentDidCatch.

### 🧪 How to test

Add the following to your kibana.yml file:

```
elastic.apm.active: true
elastic.apm.transactionSampleRate: 1.0
elastic.apm.environment: yourName <-- Change to your name
```
<details>
<summary>Throw a fatal react error</summary>

Throw an error in the [alerts
page](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)
and visit http://localhost:5601/kibana/app/observability/alerts

</details>

Then visit
[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)
filtered for `yourName` in the environment.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 2, 2025
Closes elastic/observability-dev#4463

## Summary

Since we now have support for error labels in RUM
([PR](elastic/apm-agent-rum-js#1594)), this PR
changes the way that we report rum errors to use labels similar to what
we've done for toast errors
([PR](elastic#217948)).

https://github.com/user-attachments/assets/87a06ceb-705c-4c6e-ab26-d3e5874fe5ad

### ⚠️ Note

In local development, the error is captured twice because react bubbles
up the error, but it does not happen in production:
([doc](https://react.dev/reference/react/Component#componentdidcatch-caveats))

> Production and development builds of React slightly differ in the way
componentDidCatch handles errors. In development, the errors will bubble
up to window, which means that any window.onerror or
window.addEventListener('error', callback) will intercept the errors
that have been caught by componentDidCatch. In production, instead, the
errors will not bubble up, which means any ancestor error handler will
only receive errors not explicitly caught by componentDidCatch.

### 🧪 How to test

Add the following to your kibana.yml file:

```
elastic.apm.active: true
elastic.apm.transactionSampleRate: 1.0
elastic.apm.environment: yourName <-- Change to your name
```
<details>
<summary>Throw a fatal react error</summary>

Throw an error in the [alerts
page](https://github.com/elastic/kibana/blob/main/x-pack/solutions/observability/plugins/observability/public/pages/alerts/alerts.tsx)
and visit http://localhost:5601/kibana/app/observability/alerts

</details>

Then visit
[kibana-cloud-apm.elastic.dev](https://kibana-cloud-apm.elastic.dev/app/apm/services/kibana-frontend/errors?comparisonEnabled=true&environment=ENVIRONMENT_ALL&kuery=&latencyAggregationType=avg&offset=1d&rangeFrom=now-1h&rangeTo=now&serviceGroup=&transactionType=page-load)
filtered for `yourName` in the environment.

(cherry picked from commit cea253d)
maryam-saeidi added a commit that referenced this pull request Jun 24, 2025
## Summary

When checking the Overview cluster, I noticed that we previously had
`labels.error_type` in APM. In this PR, I changed the label that I've
added in the following PRs for fatal react errors and toast errors to
use `labels.error_type` instead of `labels.errorType` for consistency.

- Toast error: #217948
- Fatal react error: #218846
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 24, 2025
## Summary

When checking the Overview cluster, I noticed that we previously had
`labels.error_type` in APM. In this PR, I changed the label that I've
added in the following PRs for fatal react errors and toast errors to
use `labels.error_type` instead of `labels.errorType` for consistency.

- Toast error: elastic#217948
- Fatal react error: elastic#218846

(cherry picked from commit 970cad1)
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Jun 25, 2025
## Summary

When checking the Overview cluster, I noticed that we previously had
`labels.error_type` in APM. In this PR, I changed the label that I've
added in the following PRs for fatal react errors and toast errors to
use `labels.error_type` instead of `labels.errorType` for consistency.

- Toast error: elastic#217948
- Fatal react error: elastic#218846
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes v8.19.0 v9.0.1 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants