Traces | Metrics | App Logs | Custom Logs | Profiling |
---|---|---|---|---|
✅ | ✅ | ✅ | ✅ | ✅ |
Prerequisites
1
Infra Agent
Infrastructure Agent (Infra Agent). To install the Infra Agent, see our Installation Guide.
2
Python Version
Python 3 version 3.8
or above. Check your Python version with the following command:Shell
3
Pip Version
pip version 23.1.2
or above. Check your pip version with the following command:Shell
Install
Step 1: Install Python
APM Package
Run the following command in your terminal:
Shell
middleware-apm
has been installed with the following command:
Shell
Step 2: Import Middleware Tracker
Add the following lines to the beginning of your application:Python 3
Step 3: Container Variables [Optional]
Docker
Applications running in a container require an additional environment variable. If your application is not running in a container, move to Step 4. Add the following environment variable to your application:Shell
The
DOCKER_BRIDGE_GATEWAY_ADDRESS
is the IP address of the gateway between the Docker host and bridge network. This is 172.17.0.1
by default.
Learn more about Docker bridge networking here Dockerfile
after the pip install
command:
Dockerfile
Kubernetes
Identify the namespace where the Infra Agent is running:Shell
Shell
Step 4: Capture Application Data
Step 4a: Setup middleware.ini
File
Create a middleware.ini
file based on the features you want to observe and place it at the root of your app directory. Specify the location of the middleware.ini
file with the MIDDLEWARE_CONFIG_FILE
environment variable.
service_name
and access_token
are required for the tracker to send data to Middleware..ini
Step 4b: Enable Custom Logs
To ingest custom logs, utilize the following functions based on desired log severity levels:Python 3
Step 4c: Stack Errors
Usetracker.record_error()
method to record a stack trace when an error occurs:
Python 3
Step 5: Deploy Your Django App [Optional]
If you are not using the Django framework in your Python application, proceed to Step 6.
Step 5a: Instrument Your App
Add the following to yourmain()
function in manage.py
:
Python
Step 5b: Start Your Django Project
Initialize your Django project with the following command:Python
Step 5c: Start Your Django Project
After initializing your application, run the following command to start your project: If the
middleware.ini
file is not in your root directory, add MIDDLEWARE_CONFIG_FILE=./path/to/middleware.ini
to the below command Python
Step 6: Start Your Project
After deploying your application, run the following command to start your project:Shell
Continuous Profiling
Continuous profiling captures real-time performance insights from your application to enable rapid identification of resource allocation, bottlenecks, and more. Navigate to the Continuous Profiling section to learn more about using Continuous Profiling with the Python APM. Need assistance or want to learn more about Middleware? Contact us at support[at]middleware.io.