question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django 2.2 uncaught exceptions not being sent

See original GitHub issue

Describe the bug: … I am not sure if it is a bug, because reading the documentation I was not able to find any explicit information talking about uncaught exceptions with Django (only with Flask), but all non handled exceptions are not being sent to APM server. However, running the test command (python manage.py elasticapm test) the event is sent successfully

Environment (please complete the following information)

  • OS: Linux (Docker image python:3.7.4)
  • Python version: 3.7.4
  • Framework and version [e.g. Django 2.1]: Django 2.2
  • APM Server version: v7.5.0
  • Agent version: 5.3.2

How to reproduce In order to tests the uncaught exceptions I did the following tests:

  • Manually inserted an raise ZeroDivisionError('APM TEST') in one of my functions outside any try/catch/
  • Executed raise ZeroDivisionError('APM TEST') using python shell (python manage.py shell)

Additional context

settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.contenttypes',
    'django.contrib.staticfiles',
    'elasticapm.contrib.django',
    ...
]


MIDDLEWARE = [
    'elasticapm.contrib.django.middleware.TracingMiddleware',
    'elasticapm.contrib.django.middleware.Catch404Middleware',
    ...
]


ELASTIC_APM = {
    'SERVICE_NAME': 'MYSERVICE',
    'SECRET_TOKEN': 'SECRETTOKEN,
    'SERVER_URL': 'SERVERURL',  # noqa
    'DEBUG': True
}

Running check command

root@26cb7a8c0615:/usr/src/app# python manage.py elasticapm check
Service name is set, good job!

SERVER_URL https://APM_ADDR:443 looks fine

DEBUG mode is disabled! Looking good!

Tracing middleware is configured! Awesome!

Looks like everything should be ready!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
romulorosacommented, Oct 8, 2020

Hi @basepi, Here is the PR https://github.com/elastic/apm-agent-python/pull/943

I will add some tests, but before I would like to make sure that the behavior implemented fits your requirements.

1reaction
basepicommented, Oct 7, 2020

Hey @romulorosa I still think this would be a cool addition. Would you mind opening a PR? Will be easier not to lose track of that way (rather than just a link to a diff).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to manage error reporting | Django documentation
Error reports are really helpful for debugging errors, so it is generally useful to record as much relevant information about those errors as...
Read more >
Sentry not logging unhandled exceptions from django
Going to a simple view that deliberately raises an exception results in an event being logged from app01, but from app02 nothing is...
Read more >
How to log uncaught exceptions in Flask routes with logging?
However, sometimes your Flask routes may encounter uncaught exceptions that cause your application to crash or return an error response.
Read more >
Celery tasks uncaught exceptions not being sent to Sentry
Django : Celery tasks uncaught exceptions not being sent to Sentry [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] ...
Read more >
Handling Application Errors — Flask Documentation (2.2.x)
Unhandled Exceptions ¶ ... When there is no error handler registered for an exception, a 500 Internal Server Error will be returned instead....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found