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

Add exception info to logger message when exceptions are ignored #611

Closed
tmarice opened this issue Jun 9, 2022 · 2 comments · Fixed by #613
Closed

Add exception info to logger message when exceptions are ignored #611

tmarice opened this issue Jun 9, 2022 · 2 comments · Fixed by #613

Comments

@tmarice
Copy link
Contributor

tmarice commented Jun 9, 2022

We're using django-redis as a session cache backend for our Django project, with DJANGO_REDIS_IGNORE_EXCEPTIONS and DJANGO_REDIS_LOG_IGNORED_EXCEPTIONS set to True.

Unfortunately, we're experiencing a pesky Redis TimeoutError, which due to the previous settings, is only getting logged as:

ERROR    django_redis.cache 2022-06-08 17:16:54,470 cache.py _decorator 35 Redis TimeoutError: Timeout reading from socket

The issue happens only in the production environment, and we can't get a full exception traceback without impacting customers, so debugging this has been difficult. We'll probably work around this by live-editing the cache module on the web servers.

What are your thoughts on using self.logger.exception instead of self.logger.error in the omit_exception decorator, or adding another setting (e.g. DJANGO_REDIS_LOG_EXCEPTION_TRACEBACK) which would control the logging behavior?

@WisdomPill
Copy link
Member

Hello @tmarice,
yes that's perfectly fine by me,
I prefer using log.exception instead of log.error but since I inherited this project I did not touched that.

You are welcome to open a PR.

If I may give you an advice to use a tracing system, like Sentry and you would never have this problem again :)

@tmarice
Copy link
Contributor Author

tmarice commented Jun 13, 2022

Excellent, I'll try to free up some time in the following weeks to work on this.

Unfortunately, Sentry doesn't help here since the exception is caught and logged. Sentry picks it up from the logger, but it's missing local variables and the full traceback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants