Skip to content

Debugging Flowdapt

The simplest method to debug Flowdapt is by utilizing the VSCode debugger.

Initially, adhere to the guidelines in our Contributor Guide for setting up your environment. Then, create or update the launch.json file in the .vscode folder at the root of the Flowdapt source code:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "python",
            "request": "launch",
            "name": "Python: flowdapt server",
            "module": "flowdapt",
            "args": ["run"]
        }
    ]
}
Hint

This folder and file can be automatically generated by pressing Ctrl-Shift-D and following the instructions in VSCode.

Subsequently, confirm that the Python interpreter is set to the virtual environment you defined during the setup. This can be done by selecting the Python interpreter in the bottom left corner of VSCode or through the command palette (Ctrl + Shift + P). Next, proceed to insert debug flags in the vicinity of the suspected bug.

Important

To ensure the debugger functions correctly, use the Local Executor.

The next step is to run the debugger with Ctrl-Shift-D and then selecting Python: flowdapt server. This is a debug version of flowdapt run. Now the server is running in debug mode, and you can interact with it as usual (e.g., through flowctl workflow run <UID>). The debugger should stop at any break points, at which point the DEBUG CONSOLE is available for interactive testing/debugging.

Tracebacks and Logging

Flowdapt's logging system allows specifying the level of detail to be logged, along with whether to render tracebacks and how many frames to use. You can set these values in your configuration like so:

logging:
  level: debug
  format: console
  include_trace_id: false
  show_tracebacks: true
  traceback_show_locals: true
  traceback_max_frames: 10

When running Flowdapt in dev mode those values are automatically set to the above defaults. You can run Flowdapt in dev mode by passing the --dev flag like so:

flowdapt --dev run

By default Flowdapt will render the logging output with the ConsoleRenderer, which is meant for development purposes to make it easier to read. During production it is recommended to use the json format instead, and setting include_trace_id to true to ensure that the trace ID is included in the logs.