Python - The Instana Python Package

Stan Loves Python

The Instana Python package: Python Distributed Tracing & Metrics Sensor.

What is Instana AutoTrace?

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 with no required user steps or restarts.

For more information, see the blog post on Python AutoTrace or the AutoTrace configuration documentation on how to modify AutoTrace behavior.


The Instana Python package is a zero-configuration tool that automatically collects key metrics and distributed traces from your Python processes.


Automatic installation

Instana remotely instruments your Python applications automatically by Instana AutoTrace™. However, if you want to install the package manually, see Manual Installation.

Manual Installation

The Instana Host agent automatically finds and instruments your running Python applications. However, you can manually install the package.

To instrument your applications, manually install the 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

Activating Without Code Changes

To activate the Instana package without any code changes, set this environment variable for your Python application:


The Instana Python package automatically instruments your Python application, and when it locates the Instana host agent, it begins to report Python metrics and distributed traces.

Activating via Import

Alternatively, to manually import the instana package to inside your Python application, run this command:

import instana

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.

Kubernetes & OpenShift

For information on how to ensure that your instrumented applications can contact the Instana Host Agent, see the documentation.

Cloud Foundry

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.

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 instana Python package to the requirements.txt file
  • Add an AUTOWRAPT_BOOTSTRAP environment variable with the value instana to the application manifest as shown below
  • cf push the Cloud Foundry application
- name: test-python-flask
    - python_buildpack

Custom Tracing

The Instana Python package supports custom tracing via OpenTracing APIs. See the OpenTracing page for more information.


Seeing something unexpected or having trouble trying to configure something? See the Python Troubleshooting page for help.


For the Instana Python package release history, including changes made to the package, see the Github Releases page.

See Also