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 rev-parse --short HEAD", shell=True, text=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 module and call the appsignal.start() method on app start or in the main method.

AppSignal also supports popular web frameworks directly, such as Django, Flask, FastAPI or Starlette. If you're using a web framework we support directly, follow the instructions for that framework instead of the generic instructions on this page.

python
# Your app file # Add this import statement 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.