The Python Agent is delivered as a module named
provides middleware for common frameworks. Download the module, import it into
your Python application, and get visibility.
- Getting the Agent
- Enabling the Agent
- Azure App Service
The agent compiles an extension during install, thus you'll need to have the following on the system prior to installing the agent:
- python header files
- the gnu compiler
- the make command
Note that some systems may provide multiple python versions, in which case you would need to specify the versioned header package such as
python3-dev that matches the python runtime.
$ sudo apt-get install python-dev g++ make
On RHEL/CentOS/Amazon Linux:
$ sudo yum install python-devel gcc-c++ make
$ sudo apk add python-dev g++ make
You can check the support matrix to make sure your system is supported.
The extension is compiled into a binary with system and Python version dependencies, so the installed agent package on one platform cannot just be copied onto a different platform; instead, the agent must be installed specifically on each different platform.
First, install the package into your application's environment:
$ pip install appoptics-apm
Now the module
appoptics_apm should be available, see below on how to enable it for your application.
The agent requires a service key to connect to your account, and must be either attached as a middleware or through custom instrumentation to your application. Read below to get set up.
The service key should be defined in the environment your application runs in (see Configuration):
$ export APPOPTICS_SERVICE_KEY="api-token-here:your-service-name-eg-python"
A service key is composed of an API token with write permisisons and the name of the service you're installing on. Our onboarding flow provides the full service key, or check the API Tokens page to grab a token and fill the service name yourself.
Instructions are provided for common frameworks below. If you don't find what you need, you can always use custom instrumentation to monitor any Python process.
To instrument your Django application, add
appoptics_apm.djangoware to the
INSTALLED_APPS tuple in your application's settings module (
INSTALLED_APPS = (
# ... your Django apps
Import AppOptics Tornado instrumentation library:Copy
from appoptics_apm import tornado_oboe
Make your handler function inherit from
logging.error("Inside Main Handler %s", appoptics_apm.Context.get\_default())
self.write("Hello, world from %s:" % appoptics_apm.Context.get\_default())
application = tornado.web.Application([
Many python apps are implemented atop WSGI, which provides a uniform interface through which web frameworks and middleware libraries interoperate. AppOptics offers a WSGI middleware component called AppOpticsApmMiddleware, which wraps your WSGI app to collect performance statistics. Install middleware instrumentation as you would any other middleware by adding it to the file that instantiates your app. But put it at the end of the list, closest to the outside of the middleware stack.
The following code demonstrates the instrumentation of Flask applications. Applications using other frameworks can also wrap the WSGI app with AppOpticsApmMiddleware class to trace the web requests.
# flask example
from flask import Flask
from appoptics_apm.middleware import AppOpticsApmMiddleware
# the flask app
app = Flask(__name__)
app.wsgi_app = AppOpticsApmMiddleware(app.wsgi_app)
return "Hello World!"
Now start your application and make some requests, check your AppOptics dashboard and you will find the trace events reported from your application.
If your Python application platform is Azure App Service on Linux, installing APM is as simple as adding the Python agent as a dependency, enabling it in your application, then redeploying.
To install the agent, add it to the application's
requirements.txt file. For example:
Finally, redeploy the application and you should see trace data and metrics shortly.
When the APM Integrated Experience is enabled, AppOptics shares a common navigation and settings with the other integrated experiences' products. How you navigate AppOptics and access its features may vary from these instructions. For more information, go to the APM Integrated Experience documentation.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.