The following content pertains to
AppOptics agents are no long receiving updates. The new SolarWinds Observability libraries can send APM data in AppOptics and are regularly updated with new features and improvements. If you are still relying on the AppOptics agents and your components are supported by the new libraries, consider transitioning to the SolarWinds Observability libraries for your APM needs. For more information about the benefits of migrating to the SolarWinds Observability libraries. Alternatively, you can use SolarWinds Observability as your primary APM solution.
If you have already transitioned to the new SolarWinds Observability Python Library, see the SolarWinds Python Library documentation for installation information.
SolarWinds Observability libraries are not compatible with AppOptics agents. Do not use a mix of SolarWinds Observability libraries and AppOptics agents to instrument applications that are part of a distributed trace.
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.
appoptics_apm package provides pre-built binary distributions (Python wheels) for most supported systems to facilitate an easy installation process.
To install the package, you only need to run
pip install appoptics-apm
This command will automatically select the Python wheel compatible with your system and install the agent. Now the module
appoptics_apm should be available, see below on how to enable it for your application.
System Requirements for Installation from Python Wheels
pip version >= 19.3
If you are running an older version, upgrade pip with the command
pip install --upgrade pip
Most modern Linux operating systems, except for Alpine Linux, will be compatible with the manylinux2014 Python wheel platform specification.
If your system does not satisfy the above requirements, you can install
appoptics_apm from the source. See Install the Agent from the Source Distribution.
appoptics_apm package provides Python wheels for version 4.4.0 and up only. Older versions of
appoptics_apm must be installed from the source distribution.
If you want to install
appoptics_apm on Alpine Linux or there's another reason you cannot install the agent from the provided Python wheels, install
appoptics_apm from the source distribution.
System Requirements for Installation from Source Distribution
The agent will compile an extension during install, thus you need to have the following on the system prior to installing the agent:
- Python header files
- the gnu compiler
- the make command
The installation of the above components is specific to the underlying operating system you are using.
sudo apt-get install python-dev g++ make
On RHEL/CentOS/Amazon Linux:
sudo yum install python-devel gcc-c++ make
On Alpine Linux:
sudo apk add python-dev g++ make
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 correct Python runtime.
You can check the Supported components (legacy agent) matrix to make sure your system is supported.
Installation from Source Distribution
Now, you can install the agent by running
pip install appoptics-apm
The extension is compiled into a binary with system and Python version dependencies, so do not copy the installed agent package from one platform onto another platform; instead, the agent must be installed specifically on each different platform.
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):
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 (
#settings.py INSTALLED_APPS = ( # ... your Django apps 'appoptics_apm.djangoware', )
Import AppOptics Tornado instrumentation library:
from appoptics_apm import tornado_oboe
Make your handler function inherit from
class MainHandler(tornado_oboe.AppOpticsApmBaseHandler): def get(self): logging.error("Inside Main Handler %s", appoptics_apm.Context.get\_default()) self.write("Hello, world from %s:" % appoptics_apm.Context.get\_default()) self.finish() ... tornado.options.parse_command_line() application = tornado.web.Application([ (r"/", MainHandler), ], **settings) application.listen(options.port) tornado.ioloop.IOLoop.instance().start()
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) @app.route("/") def hello(): 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:
Flask Jinja2 .. appoptics-apm
Finally, redeploy the application and you should see trace data and metrics shortly.
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.