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.

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

Configuration using a 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:

solution        = Solution_Name
application     = App_Name         # if this is not present then Application is set to absolute path of script name
#release        =                  # should be set to a git hash of current release commit 
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).
host            = 127.0.0.1        # RevDeBug server address
apm             = 1                # 0 or 1, whether APM functionalyty is enabled or not
#force_tls       = 0               # 0 or 1, whether the RevDeBug server uses a secure connection

#exc_rec_http_in          = 403, 404        # http status codes to be excluded from auto exception recordings for servers (span will still be recorded)
#exc_rec_http_out         = 403, 404        # http status codes to be excluded from auto exception recordings for clients (span will still be recorded)

#version        = Version_String   # Human readable version string, e.g. "1.0", etc...)
#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 '+').
#conn_timeout   = 4                # connection timeout in seconds
#reconn_wait    = 60               # maximum wait before reconnect attempt (reached with exponential backoff)
#port           = 42734
#auth           =                  # authentication token for server access
#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)
#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

#sw_agent_name            = App_Name   # name of the service for APM topology and traces
#sw_agent_disable_plugins = sw_django  # APM tracing support to disable
#sw_ignore_suffix         = .jpeg,.jpg
#sw_trace_ignore_path     = /metrics

# You can control what parts of your application sources you would like to have RevDeBug to record when error happens
# Record path examples:
#record      = +/this/path/will/be/recorded/even/if/it/is/in/a/system/library/
#record      = ../this/relative/path/from/.cfg/file/as/well
#record      = -this/file/will/not/be.py
#record      = -/neither/will/this.py:-or/this/path:/but/this/file/will/be

You can read more about configuration options here

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 updated