Forward Errors to Sentry

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text :slight_smile:

Kibana version: 7.4.1

Elasticsearch version: 7.4.1

APM Server version: 7.4.1

APM Agent language and version: Python 5.2.2

Browser version:

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

Fresh install or upgraded from other version?: Fresh

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant): I'm using Sentry to capture all errors. After using Elastic APM, all unhandled errors are captured by APM and Sentry couldn't get it. Is there any way to forward all errors from Elastic APM to Sentry or remove capturing errors by Elastic APM.

Thanks everyone,
Thien

Hi @Thien_Ho

thanks for opening the topic! There isn't a way to forward errors to Sentry, but theoretically speaking, that shouldn't be necessary, as for both Django and Flask, we subscribe to a signal (got_request_exception), and don't swallow the exception. As far as I know, Sentry does the same. So both ours and Sentry's signal handler should receive and handle the exception.

That being said, you could try and disconnect our signal handlers and see if that helps.

For Django, something like this should work:

from django.core.signals import got_request_exception

got_request_exception.disconnect(dispatch_uid="elasticapm-exceptions")

Ideally, you'd create a new Django app similar to the example in the Django docs and put the code above into the ready method.

For Flask, the code snippet looks similar:

from flask.signals import got_request_exception
from elasticapm.contrib.flask import ElasticAPM

got_request_exception.disconnect(ElasticAPM.handle_exception)

You'd put that code in your flask app right after initializing ElasticAPM.

Let me know if that helps!

1 Like