AppSignal Python Configuration

This documentation explains how to configure AppSignal. For more information on installing AppSignal, follow the steps in our installation documentation.

Application Environment

By default, the AppSignal for Python integration will report the current application in the "development" environment. You can use the environment configuration option to set a different environment. For example, in your __appsignal__.py file:

python
# __appsignal__.py appsignal = Appsignal( # ... environment="production" )

You can also use the APPSIGNAL_APP_ENV environment variable.

Reporting Deploys

You can use Deploy Markers to report new deploys of your Python application. You can combine Deploy Markers with Backtrace Links to directly link from AppSignal to the source code on platforms like GitHub and GitLab.

Deploy markers can be configured using the revision config option or the APP_REVISION environment variable. We recommend using Git commit SHAs or a tag in your SCM. For example, for Git applications, add the following code to the __appsignal__.py file:

python
# __appsignal__.py import subprocess revision = None try: revision = subprocess.check_output( "git log --pretty=format:'%h' -n 1", shell=True ).strip() except subprocess.CalledProcessError: pass appsignal = Appsignal( # ... revision=revision )

Importing the Configuration File

The AppSignal for Python integration needs to be loaded and started in your application. To load and start the integration, import the appsignal value from the __appsignal__ module at the top of your file and call the appsignal.start() method on app start or in the main method.

For Django applications, this means adding an import statement to the manage.py file and calling appsignal.start() in the main() method. See the Django install instructions for more information.

python
# Your app file # Add this import statement from __appsignal__ import appsignal def main(): # Add this method call appsignal.start() if __name__ == '__main__': main()

Add Instrumentation Packages

The next step is to instrument Python libraries such as Django, Celery, etc. Instrumenting libraries will provide a broader set of monitoring data, allowing you to understand your application's performance better.

You can read more about installing and configuring instrumentations in our Python instrumentations documentation.