Python Configuration
Configuration Options
The Python agent can be configured via three methods:
- Scout Config
- Framework dependent variables
- Environment Variables
Scout Config
from scout_apm.api import Config
Config.set(
key="[AVAILABLE IN THE SCOUT UI]",
name="A FRIENDLY NAME FOR YOUR APP",
monitor=True,
)
Framework Dependent
Certain frameworks have other ways that Scout variables can be configured, such as in settings.py for Django and app.config for Flask. See framework pages for more details.
Environment Variables
You can also configure Scout APM via environment variables. To configure Scout via environment variables, uppercase the config key and prefix it with SCOUT_
. For example, to set the key
configuration via environment variables use: export SCOUT_KEY=YOURKEY
Common Configurations
Setting Name | Description | Default | Required |
---|---|---|---|
key | The organization API key. | Yes | |
name | Name of the application (ex: ‘Photos App’). | Yes | |
monitor | Whether monitoring data should be reported. | False |
Yes |
revision_sha | The Git SHA associated with this release. Used with Deploy Tracking. | See docs | No |
Additional Configurations
Setting Name | Description | Default | Required |
---|---|---|---|
collect_remote_ip | Automatically capture end user IP addresses as part of each trace’s context. | True |
No |
disabled_instruments | An list of instruments that Scout should not install. If specified as an environment variable, it should be a comma-separated list. The default installed instruments can be viewed in the agent source. | [] |
No |
errors_ignored_exceptions | Excludes certain exceptions from being reported. | () |
No |
hostname | The hostname the metrics should be aggregated under. | hostname |
No |
ignore | A list of (relative) URL path prefixes to avoid collecting metrics for. If errors are enabled, they will be captured for these URL path prefixes still. If specified as an environment variable, it should be a comma-separated list. | [] |
No |
log_content_payload | Logs the payload of the messages being sent to the core-agent and error service. This should only be enabled for debugging. | False |
No |
scm_subdirectory | The relative path from the base of your Git repo to the directory which contains your application code. | No | |
showdown_timeout_seconds | Maximum amount of time, in seconds, to spend at flushing outstanding events to the core agent at shutdown. Set to 0 to disable. | 2.0 | No |
uri_reporting | By default Scout reports the URL and filtered query parameters with transaction traces and error reports. Sensitive parameters in the URL will be redacted. To exclude query params entirely, use path . |
filtered_params |
No |
Core Agent Configurations
There are also some configuration options that affect how the core agent process is run. Typically you don’t need to change these:
Setting Name | Description | Default | Required |
---|---|---|---|
core_agent_dir | Path to create the directory which will store the Core Agent. | /tmp/scout_apm_core |
No |
core_agent_download | Whether to download the Core Agent automatically, if needed. | True |
No |
core_agent_full_name | The release/url we look for when downloading the core-agent. | Auto-detected | No |
core_agent_launch | Whether to start the Core Agent automatically, if needed. | True |
No |
core_agent_log_file | The log file for the Core Agent to write its logs to. If not set, it won’t be written. This does not affect the logging configuration of the Python library. To change that, directly configure the python logging module as per the below documentation. Prior to version 2.13.0, this was called log_file. That name now works as an alias, and takes precedence to allow old configuration to continue to work. |
No | |
core_agent_log_level | The log level of the Core Agent. This should be one of: "trace" , "debug" , "info" , "warn" , "error" . This does not affect the log level of the Python library. To change that, directly configure the python logging module as per the below documentation. Prior to version 2.6.0, this was called log_level. That name now works as an alias, and takes precedence to allow old configuration to continue to work. |
"info" |
No |
core_agent_permissions | The permission bits to set when creating the directory of the Core Agent. | 700 |
No |
core_agent_config_file | Point to a configuration file for the Core Agent. This may be useful for debugging your setup with files provided by Scout APM staff. | Prior to version 2.13.0, this was called config_file. That name now works as an alias, and takes precedence to allow old configuration to continue to work. | No |
core_agent_triple | If you are running a MUSL based Linux (such as ArchLinux), you may need to explicitly specify the platform triple. E.g. x86_64-unknown-linux-musl |
Auto detected | No |
core_agent_socket_path | The path to the socket to connect to the Core Agent, passed to it when launching. This may be either a TCP address, in the format tcp://<address>:<port>, or an absolute path to create as a Unix socket. The deafult is to use TCP. Prior to version 2.16.0, this defaulted to using a Unix socket in the same directoy as the core agent. Prior to version 2.13.0, this was called socket_path. That name now works as an alias, and takes precedence to allow old configuration to continue to work. | tcp://127.0.0.1:6590 |
No |
Environments
It typically makes sense to treat each environment (production, staging, etc) as a separate application within Scout and ignore the development and test environments. Configure a unique app name for each environment as Scout aggregates data by the app name.
Ex:
export SCOUT_KEY=YOURKEY
export SCOUT_NAME=YOURAPPNAME (Production)