Monitoring Python - The Instana Python Package
TABLE OF CONTENTS
The Instana Python package: Python Distributed Tracing & Metrics Sensor.
Instana AutoTrace™ is a next-generation distributed tracing and service discovery technology powering Instana’s fully automatic, no-effort, and instant observability experience.
The Instana Host agent automatically finds and instruments your running Python applications running on Linux x86 with no required user steps or restarts.
The Instana Python package is a zero-configuration tool that automatically collects key metrics and distributed traces from your Python processes.
Instana remotely instruments your Python applications automatically by Instana AutoTrace™. However, if you prefer to install the package manually, see Manual Installation below.
Note: Instana AutoTrace™ support for Python requires the instrumenting machine to be able to reach
As such, it won't work in air-gapped environments or similar environments that restrict egress.
In such cases, use the Manual Installation method.
You can manually install the Instana Python package into the virtualenv, pipenv, or container (hosted on pypi) by running this command:
pip install instana
To update an existing installation, run this command:
pip install -U instana
From here there are two options available to choose from based on your organization's needs described below.
Instana offers a way of activating the Instana Python package without modifying a single line of code in your application. This allows you to avoid many of the processes involved with application code changes such as pull-requests, quality assurance, staging and deployment to production.
To activate the Instana package without any code changes, simply set the following environment variable for your Python application:
The Instana Python package will automatically load on application boot and instrument your Python application.
- Note: This method of activation will not work with applications based on
gevent. This is because
geventmust be activated and
Alternatively, to manually import the
instana package to inside your Python application code, add the following to your application code:
For additional information about Django, Flask, End-user Monitoring (EUM), and more, see the Frameworks section.
For out of the box metrics and distributed tracing, no configuration is required. However, individual components are configurable. For more information, see the Python configuration.
For information on how to ensure that your instrumented applications can contact the Instana Host Agent, see the documentation.
Note: This section assumes that the Instana agent is running on the Diego cells of the Cloud Foundry foundation. Without an agent running on the underpinning Diego cell, monitoring Cloud Foundry applications is not supported.
Additionally, since the Tile version 1.177.0, the
instana_buildpack automates the setup of Python applications on Cloud Foundry.
For more information, refer to the Instana Buildpack documentation.
For information on how to setup Instana agents and the related Cloud Foundry or Pivotal Platform functionality, see our Cloud Foundry and Pivotal Platform documentation.
Monitoring Python Cloud Foundry applications requires the following steps:
- Add the
instanaPython package to the
- Add an
AUTOWRAPT_BOOTSTRAPenvironment variable with the value
instanato the application manifest as shown below
cf pushthe Cloud Foundry application
--- applications: - name: test-python-flask buildpacks: - python_buildpack env: AUTOWRAPT_BOOTSTRAP: instana
The Instana Python package supports custom tracing via OpenTracing APIs. See the OpenTracing page for more information.
Please see our dedicated Troubleshooting documentation.
For the Instana Python package release history, including changes made to the package, see the Github Releases page.