Installation
🐍 Don’t forget to install the AppSignal for Python package in your application first.
opentelemetry-instrumentation-wsgi or the opentelemetry-instrumentation-asgi package, depending the gateway interface used in the application. To add it to your project, add the following line to your requirements.txt file:
Setup
In your application’s entry point (usually namedmain.py or app.py), before your application is initialised, call appsignal.start() to start your application:
OpenTelemetryMiddleware from the corresponding OpenTelemetry instrumentation, and wrap your application with it:
Grouping routes
By default, a generic WSGI or ASGI instrumentation will not have the necessary context to understand how routing is structured in your application. As such, the performance samples that AppSignal receives will not be grouped correctly. You must add routing information to the OpenTelemetry span manually. One way to do so is by following OpenTelemetry’s HTTP semantic conventions, setting thehttp.route attribute in your route handlers:
GET /users/:user_id in the AppSignal performance samples panel.
If you prefer to group requests in some other way (for example, by referring to the method or class that implements them) you can use the appsignal.root_name attribute:
appsignal.root_name, the request method will not be used. The value provided (in this case, UserHandlers#show) will be used to group all requests handled by this method.