APM Errors not Showing in Kibana

Steps To Repro:

  • Create new Angular 8 project using Angular CLI

  • Add APM Rum agent following the instructions from the official documentation

  • Throw Error on App Init

      ngOnInit() {
          throw Error('Error occured');
        }
    

Navigate to the cloud Kibana APM and notice that Transactions are logged in correctly but the Error is not getting logged.

Kibana version: 7.5.0

Elasticsearch version: 7.5.0

APM Server version: 7.5.0

APM Agent language and version: apm-rum-angular v3

Browser version: any

Original install method (e.g. download page, yum, deb, from source, etc.) and version:

Fresh install or upgraded from other version?: Fresh

Is there anything special in your setup?: No

Errors in browser console (if relevant):

image

Hi Aleksandra,

Thanks for trying out Elastic APM Integration. Had a quick look and it seems that the default integration of Angular Error Handler prints the error message to the console and does not rethrow them as ErrorEvent which means the RUM agent won't be able to track it automatically.

However there is an recommended approach from the Angular docs to implement a custom ErrorHandler for the application module and we could use that to capture errors in APM easily.

import { ErrorHandler } from '@angular/core'
import { apm } from '@elastic/apm-rum'

export class APMErrorHandler implements ErrorHandler {
  handleError(error) {
    apm.captureError(error)
  }
}

and you would have to use that in your Application Module in this way

@NgModule({
  providers: [{provide: ErrorHandler, useClass: APMErrorHandler}]
})
class MyModule {}

Please refer to the Angular docs - https://angular.io/api/core/ErrorHandler and do let us know if you run in to any issues.

Thanks,
Vignesh

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.