Python APM

To get the most out of Middleware OpsAI for your Python application, Consider using Middleware Python SDK (version 2.4.0 or newer).

πŸš€ Key Features

  • See the exact code that caused your error: Whenever an exception happens, Middleware SDK automatically captures and sends the code of the function where the error occurred. This helps you quickly understand what went wrongβ€”no more guessing from just a stack trace!
  • Works with all OpenTelemetry-supported Python frameworks

πŸ› οΈ APM Setup

  1. Install the Middleware package:

  2. Run your app with Middleware CLI:

    The install adds a middleware-run CLI to your virtual environment. Use it to start your app:

    • Instead of:
    • Use:

⚑ Exception Code Capturing

Middleware Python SDK automatically captures relevant code for real-time exceptions, without any additional configurations

βš™οΈ VCS Metadata Configuration (Recommended)

To help Middleware suggest fixes and even open GitHub pull requests for you, it's important to send version control (VCS) information along with your error data.

  • If your app has a .git directory:

    • The Middleware SDK will automatically detect your repository URL and commit SHA. You don't need to do anything extra!
  • If your app is running in a container or doesn't have a .git directory:

    • Set these environment variables before starting your app:

    • This lets Middleware know exactly which version of your code is running, so it can suggest the right fix and even create a solution PR for you.

πŸ“š Resources