How to Configure PyCharm for Sentry Development

This guide walks through the required PyCharm settings—including interpreter selection, run/debug configurations, pytest integration, devserver options, and troubleshooting tips—so developers can run and debug the Sentry codebase effectively within the IDE.

Hacker Afternoon Tea
Hacker Afternoon Tea
Hacker Afternoon Tea
How to Configure PyCharm for Sentry Development

If you develop Sentry with PyCharm, you must configure several settings before you can run and debug the project.

Interpreter : Set the Python interpreter to a virtual‑env interpreter, e.g. ~/venv/sentry/bin/python.

To create a run/debug configuration, open Run | Edit Configurations… in PyCharm.

Test runner

Sentry uses pytest for unit tests. Create a pytest configuration under Python tests, set the target to Custom , and add the additional arguments tests/sentry.

Dev server with all components

Create another Python configuration with the following fields:

Script path: <venv dir>/bin/sentry (e.g. ~/venv/sentry/bin/sentry)

Parameters: devserver --workers Python interpreter: the same venv interpreter

Working directory: the src directory of the Sentry installation, e.g. ~/dev/sentry/src Note: This configuration cannot debug the Web Worker, which is started via uwsgi.

Debugging with PyCharm

The devserver command spawns a daemon, so the debugger cannot attach by default. Clone the devserver configuration, append --debug-server to the Parameters field, and select Debug instead of Run to start it.

The --debug-server flag may interfere with proper SIGINT handling and cause a less graceful shutdown. It is recommended to keep two separate configurations: one with Run (no flag) and one with Debug (with the flag).

You can keep the --workers flag together with --debug-server, but breakpoints cannot be attached to the worker processes or any other daemons started by devserver.

Independent daemon

To attach the debugger to a non‑web daemon, clone the devserver configuration and modify only the Parameters field. Use the same script path, interpreter, and working directory as the devserver configuration.

Tips and troubleshooting

If you need to debug the getentry project, apply the same modifications to its run configuration.

PyCharm’s Compound run configuration type is useful for launching multiple configurations (e.g., the devserver and an independent daemon) together.

To change Sentry’s behavior in a debug environment, add custom environment variables and read them in .sentry/sentry.conf.py. For example, disabling APM sampling during debugging.

The variable PYCHARM_DEBUG is arbitrary; it has no special meaning for PyCharm or Sentry.

When a standalone daemon does not work, debug it by running devserver --debug-server and setting a breakpoint in src/sentry/runner/commands/devserver.py. Look for the manager.add_process call and adjust the parameters in the run configuration accordingly.

Additional reference links are provided for deeper Sentry documentation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

debuggingPythonConfigurationSentrypycharmpytestdevserver
Hacker Afternoon Tea
Written by

Hacker Afternoon Tea

You might find something interesting here ^_^

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.