Skip to main content

[Python] Why is a stack trace not attached to my errors in Sentry?

Issue

Errors in Sentry are missing stack traces, making it difficult to debug the issue.
​
​

Resolution

  • Check if you are logging a message event:
    ​

    • Message events, created using capture_message(), do not include a stack trace by default. They capture simple log messages without stack trace details.
      ​

  • Use capture_exception() for stack traces:
    ​

    • To get stack traces, use capture_exception() instead of capture_message(). Exception events include stack traces automatically.
      ​

  • Enable stack traces for message events:
    ​

    • If you need a stack trace for message events, enable the attach_stacktrace option in the Sentry SDK init.

    • This ensures stack traces if available are attached to all message-level events.

Did this answer your question?