PostgreSQL Instrumentation

Installation

Don't forget to install the AppSignal for Python package in your application first.

The installation instructions differ based on the PostgreSQL adapter package you are using:

When using SQLAlchemy, do not install these instrumentation packages. The instrumentation for SQLAlchemy will automatically instrument queries to the underlying database. Installing both instrumentation packages will result in duplicate events.

Using aiopg

AppSignal for PythonThis feature requires version 1.3.2 or higher.
aiopgThis feature requires version 0.13.0 or higher.

When using the aiopg PostgreSQL adapter package, install the opentelemetry-instrumentation-aiopg package. To add it to your project, add the following line to your requirements.txt file:

shell
# requirements.txt opentelemetry-instrumentation-aiopg

Using asyncpg

AppSignal for PythonThis feature requires version 1.3.2 or higher.
asyncpgThis feature requires version 0.12.0 or higher.

When using the asyncpg PostgreSQL adapter package, install the opentelemetry-instrumentation-asyncpg package. To add it to your project, add the following line to your requirements.txt file:

shell
# requirements.txt opentelemetry-instrumentation-asyncpg

Using psycopg2

AppSignal for PythonThis feature requires version 0.1.0 or higher.
psycopg2This feature requires version 2.7.3.1 or higher.

When using the psycopg2 PostgreSQL adapter package, install the opentelemetry-instrumentation-psycopg2 package. To add it to your project, add the following line to your requirements.txt file:

shell
# requirements.txt opentelemetry-instrumentation-psycopg2

Using psycopg

AppSignal for PythonThis feature requires version 1.3.1 or higher.
psycopgThis feature requires version 3.1.0 or higher.

When using the psycopg (version 3) PostgreSQL adapter package, install the opentelemetry-instrumentation-psycopg package. To add it to your project, add the following line to your requirements.txt file:

shell
# requirements.txt opentelemetry-instrumentation-psycopg

The AppSignal for Python integration will automatically use this instrumentation when the corresponding package is installed. To disable this instrumentation without uninstalling the package, use the disable_default_instrumentations configuration option.