Instrument Python Applications

AppDynamics Pro Documentation Version 4.0.x

Page 1 Instrument Python Applications ...... 3 Python Supported Environments ...... 9 AppDynamics for Python Architecture ...... 11 Python Agent Settings ...... 12 Disable the Python Agent ...... 16 Upgrade the Python Agent ...... 16 Python Agent Debugging and Logs ...... 17 Start and Stop the Pyagent Proxy Manually ...... 18

Page 2 Instrument Python Applications

On this page: Before You Begin Install the Python Agent Configure the Agent Instrument the Application Related pages: Python Agent Settings Python Supported Environments AppDynamics for Python Architecture Disable the Python Agent Upgrade the Python Agent Python Agent Debugging and Logs Rate this page:

Before You Begin

1. Confirm you have access to a 4.0 or later AppDynamics controller: If you use a SaaS controller, AppDynamics sent you the controller host name in your Welcome email. If you use the on-premise controller, you supplied the host and port when you installed the controller. 2. Verify that your Python environment meets the following requirements: CPython 2.6 or CPython 2.7 pip 1.4 or later access to the Python Package Index (https://pypi.python.org/) by the machine on which you will install the agent 3. Verify that you have a WSGI-based application to monitor. See Supported Environments and Versions for Python. 4. If the application that you will monitor runs in a virtual environment, activate the virtual environment. This is not necessary if the application runs in the global Python environment.

Example of activating a virtual environment:

source //bin/activate

Install the Python Agent

Copyright © AppDynamics 2012-2015 Page 3 The machine that the application is running on must have access to the Python Package Index (htt ps://pypi.python.org/). To install the agent package in the virtual environment you need to be the user who owns that virtual environment. Install the agent into the virtual environment after you have activated it. If the application uses the global Python environment, you need to run the install command as root. To install the agent and its dependencies, run the pip install command as follows:

pip install -U appdynamics\<4.1

When there are multiple packages, you can locate the agent using the pip list command or using the List packages facility at https://pypi.python.org/pypi and then find "appdynamics" in the output. Here is sample output from the List packages command:

Configure the Agent

Provide a configuration file that specifies at least the minimal AppDynamics settings for communication between the agent and the controller. The configuration file should be in the Python ConfigParser format. The Python application user must have read access on the configuration file. Note that lines in the configuration file must not start with spaces. Lines that begin with a # are comments and are ignored by the agent, Here is a simple sample configuration file with the minimal settings.

Copyright © AppDynamics 2012-2015 Page 4 [agent] app = tier = node =

[controller] host = port = ssl = on|off account = accesskey =

The ssl setting is off by default. Set it to on if you are connecting to the controller via SSL. The account and accesskey are required if you are using a SaaS account or a multi-tenant on-premise controller. Other settings, such as ssl or http-proxy or wsgi_module, may be required depending on your application deployment. See Python Agent Settings for the complete list of settings. You can store this configuration file anywhere. When you instrument an application using pyagent run, you pass the configuration file's path as a parameter to the pyagent run command. In other deployments set the APPD_CONFIG_FILE environment variable as illustrated below in the samples