Set up PHP applications
Use the OpenTelemetry PHP extension and SDK to export application telemetry. See the connection details first.
Install the extension and SDK
pecl install opentelemetry
composer require open-telemetry/sdk open-telemetry/exporter-otlp php-http/guzzle7-adapterEnable the extension in php.ini:
extension=opentelemetry.soInstall the auto-instrumentation package for your actual framework. For example, the Slim setup uses open-telemetry/opentelemetry-auto-slim.
For the Monolog logging integration, install monolog/monolog and open-telemetry/opentelemetry-logger-monolog and connect OpenTelemetry\Contrib\Logs\Monolog\Handler to your logger. Exporter environment settings alone do not connect an existing logger.
Configure the process
Create the shared environment file and add:
OTEL_PHP_AUTOLOAD_ENABLED="true"Load the file, then build authentication and set the standard SDK header. The endpoint is the base HTTPS URL and the protocol is http/protobuf.
For PHP-FPM, supply these values through the pool's environment so the worker processes can read them. For command-line PHP, start the app from the configured shell. The SDK reads the process environment on Linux or Windows.
Restart the PHP processes, generate a log entry and application requests, then check the result.