Python
How to setup recording & monitoring for Python applications
RevDeBug supplies a ready Docker container based on vanilla Debian Buster docker images that can be used as a drop-in replacement for your own microservices:
docker.revdebug.com/python-revdebug:latest
The Docker image can be used also to run a separate Python interpreter process to run applications outside the container as well.

Supported Python runtime versions

    3.8.9
    3.9.1 (available soon)

Configuration using configuration file

The RevDeBug Python configuration is first read from an optional revdebug.cfg file in the current working directory of your application. Those settings can be set or overridden through environment variables.
Then the script base directory is checked for the file again and if it is present it is read and overrides any settings from the previous file (if one was read). Finally environment variables are checked and override anything which may have come from a config file.
The config file options (case insensitive) are as follows:
1
solution = Solution_Name
2
application = App_Name # if this is not present then Application is set to absolute path of script name
3
#release = # should be set to a git hash of current release commit
4
mode = OnEvent # can be "Continuous", "OnEvent" or "Off" (case insensitive) (if mode is off then can not be enabled from remote server and just acts like normal Python).
5
host = 127.0.0.1 # RevDeBug server address
6
apm = 1 # 0 or 1, whether APM functionalyty is enabled or not
7
8
exc_status = 401, 403, 404 # http status codes to be excluded from auto-exception record for SERVERS, APM clients receiving these error codes will always record
9
10
#record = Record:paths # ':' delimited list of absolute or relative (to .cfg) paths or files to enable or disable recording (using '+' or '-' prefix, no prefix is same as '+').
11
#port = 42734
12
#authtoken = # authentication token for server access
13
#reprlevel = 0 # 0 .. 2, 0 = fastest least detail, 1 = fast know type stringifiers and repr for others, 2 = same as 1 but known mutable objects are shown with repr if Mutable flag not set (keep in mind values recorded may not be fully correct)
14
#mutable = 1 # 0 or 1, if set then tuples, lists, dicts, sets and bytearrays will be stringified immediately on record to be able to display the correct value at point of record
15
16
#apm_host = 127.0.0.1 # host of RevDeBug APM server
17
#apm_port = 11800 # port of APM OAP server
18
#sw_agent_name = App_Name # name of the service for APM topology and traces
19
#sw_agent_disable_plugins = sw_django # APM tracing support to disable
20
#sw_ignore_suffix = .jpeg,.jpg
21
#sw_trace_ignore_path = /metrics
22
23
# You can control what parts of your application sources you would like to have RevDeBug to record when error happens
24
#record = +/this/path/will/be/recorded/even/if/it/is/in/a/system/library/
25
#record = ../this/relative/path/from/.cfg/file/as/well
26
#record = -this/file/will/not/be.py
27
#record = -/neither/will/this.py:-or/this/path:/but/this/file/will/be
Copied!

Configuration using environment variables

Environment variables corresponding to options in the configuration file. Those have precedence over the configuration file and can be used without the configuration file present at all.
1
REVDEBUG_SOLUTION
2
REVDEBUG_APPLICATION
3
REVDEBUG_RELEASE
4
REVDEBUG_BACKLOG
5
REVDEBUG_REPRLEVEL
6
REVDEBUG_MUTABLE
7
REVDEBUG_THREADS
8
REVDEBUG_MODE
9
REVDEBUG_APPLICATIONS_HOST
10
REVDEBUG_APPLICATIONS_PORT
11
REVDEBUG_AUTH
12
REVDEBUG_RECORD # this bases relative paths from cwd on execution
13
REVDEBUG_EXC_STATUS
14
REVDEBUG_APM
15
REVDEBUG_APM_HOST
16
REVDEBUG_APM_PORT
Copied!

Minimal set of configuration required

    REVDEBUG_SOLUTION - application or project name.
    REVDEBUG_RELEASE - should be set to a git hash of a current release commit.
    REVDEBUG_APPLICATIONS_HOST - fully qualified domain name or IP address of RevDeBug Server.
    REVDEBUG_MODE - should be set to OnEvent for on error recording, other possible values are Off (still can gather APM metrics, see setting below) or Continuous for live from start to program stop recording.
    REVDEBUG_APM - should be set to 1 for application performance metrics collection or 0 to disable.
Last modified 4mo ago