open-telemetry / opentelemetry-auto-wordpress
OpenTelemetry auto-instrumentation for Wordpress
Requires
- php: ^8.0
- ext-opentelemetry: *
- nyholm/psr7: ^1
- nyholm/psr7-server: ^1
- open-telemetry/api: ^1.0
- open-telemetry/sem-conv: ^1.24
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- 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.18.4
- vimeo/psalm: ^5.0
README
This is a read-only subtree split of https://github.com/open-telemetry/opentelemetry-php-contrib.
OpenTelemetry Wordpress auto-instrumentation
Please read https://opentelemetry.io/docs/instrumentation/php/automatic/ for instructions on how to install and configure the extension and SDK.
Requirements
- OpenTelemetry extension
- OpenTelemetry SDK + exporter (required to actually export traces)
- WordPress installation
- OpenTelemetry SDK Autoloading configured
Overview
OpenTelemetry depends on composer, unlike Wordpress. This extension was developed against johnpbloch/wordpress-core, but it should also work with other installation methods.
An example in Docker of extending the official Wordpress image to enable auto-instrumentation: https://github.com/open-telemetry/opentelemetry-php-contrib/tree/main/examples/instrumentation/Wordpress
apache
Configure (eg via .htaccess
) a PHP prepend file to initialize composer:
php_value auto_prepend_file /var/www/vendor/autoload.php
This will install the composer autoloader before running Wordpress. As part of composer autoloading, scripts are executed for installed modules, importantly:
- OpenTelemetry SDK Autoloader
- this library's
_register.php
file
Installation via composer
$ composer require open-telemetry/opentelemetry-auto-wordpress
Configuration
The extension can be disabled via runtime configuration:
OTEL_PHP_DISABLED_INSTRUMENTATIONS=wordpress