open-telemetry / opentelemetry-auto-postgresql
OpenTelemetry auto-instrumentation for postgresql
Installs: 1 395
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/open-telemetry/opentelemetry-auto-postgresql
Requires
- php: ^8.2
- ext-opentelemetry: *
- ext-pgsql: *
- open-telemetry/api: ^1.0
- open-telemetry/sem-conv: ^1.30
- symfony/polyfill-mbstring: ^1.31
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- open-telemetry/sdk: ^1.0
- phan/phan: ^5.0
- php-http/mock-client: *
- phpstan/phpstan: ^1.1
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.19.2
- vimeo/psalm: 6.4.0
Suggests
- ext-mbstring: For better performance than symfony/polyfill-mbstring
This package is auto-updated.
Last update: 2025-10-22 12:56:21 UTC
README
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
OpenTelemetry PostgreSQL auto-instrumentation
Please read https://opentelemetry.io/docs/instrumentation/php/automatic/ for instructions on how to install and configure the extension and SDK.
Overview
This package provides auto-instrumentation for the PostgreSQL native PHP extension (ext-pgsql).
Hooks are registered via Composer, and client spans are automatically created for key database operations.
Supported functions include:
Connection
pg_connectpg_pconnect
Queries
pg_querypg_query_paramspg_send_querypg_send_query_paramspg_get_result
Prepared Statements
pg_preparepg_send_preparepg_executepg_send_execute
Table/Row Operations
pg_insertpg_selectpg_updatepg_delete
COPY
pg_copy_frompg_copy_to
Large Objects (LOB)
pg_lo_createpg_lo_openpg_lo_writepg_lo_readpg_lo_read_allpg_lo_unlinkpg_lo_importpg_lo_export
Configuration
Disabling PostgreSQL instrumentation
The extension can be disabled via runtime configuration:
OTEL_PHP_DISABLED_INSTRUMENTATIONS=postgresql
Database Context Propagation
Enable context propagation for database queries by installing the following packages:
composer require open-telemetry/opentelemetry-sqlcommenter
Currently, only the following functions support context propagation:
pg_querypg_send_query
Compatibility
PHP 8.2 or newer is required