Stack traces and local variable dump for django


#1

Hi,

I have configured sentry in my django application but I am not able to see stack traces or local variable traces in the Sentry logs. I am using Django 1.11. Django application is configured with uwsgi. Nginx is in front of the application and nginx acts as the proxy.

Could you please let me know if I need to setup anything more or configure anything else to view the stack traces or local variable traces? Without them the tool will be of no use.

Thanks,

Pinakee


#2

Hi @pinakee, whether a stacktrace is available depends on the kind of event you’re seeing in Sentry. Are you talking about a regular 500 Internal Server Error, or something like a log statement? Could you share an event that looks wrong in your opinion?


#3

Hi @untitaker,

Thanks for your response.

I was probably looking at the wrong issue. I had just installed sentry and was testing how it worked. When 500 Internal Server Error was sent/reported. there were bunch of other issues also were reported along with it. They were raised from the same URL . Hence, I guess I was looking at the wrong issue (I am not sure though why those issues were reported too). It contained SQL breadcrumbs and details about the packages etc instead of the stack trace. Then I figured out the correct one. I have deleted the issues - I can share if issues show up again.
But could you let me know why there were bunch of other logs/issues along with the exception one?

Thanks,
Pinakee


#4

By default the new SDK sends each error log from any logger as event, even if there’s no stacktrace attached.


#5

Hi @untitaker,

Thanks for your response. I just want the 500 internal server exceptions with function and data traces. Could you please let me know if there is a way to restrict/filter the events to only that?

Thanks,
Pinakee


#6

You can take an opt-in to capturing data by setting default_integrations=False. Maybe a less radical approach would be to explicitly configure the logging integration to not capture error logs (https://docs.sentry.io/platforms/python/logging/):

import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration

sentry_logging = LoggingIntegration(
    level=logging.INFO,        # Capture info and above as breadcrumbs
    event_level=None  # no events
)
sentry_sdk.init(
    dsn="https://16427b2f210046b585ee51fd8a1ac54f@sentry.io/1",
    integrations=[sentry_logging]
)

#7

Hi @untitaker, Thanks for the solution. It was helpful in eliminating the noise from the loggers. The logging link you have shared is useful if I want to ignore specific loggers.

Thanks,
Pinakee