Skip to content

PHP

The agent traces PHP 7.0 through 8.x applications with no code change, by attaching tracing to the PHP runtime and reloading it gracefully. PHP works on Linux and Docker. On Kubernetes it’s covered by eBPF, and it isn’t traced on Windows. For the shared opt-in flow, see the Application APM overview.

The agent produces route-level server spans, database spans (for example, PDO calls), and error spans. It propagates W3C trace context (traceparent), so a PHP span shares its trace with eBPF monitoring and with any upstream or downstream service.

When you instrument a PHP service, the agent adds a config file for the target’s PHP build, then reloads the process manager gracefully (a php-fpm or Apache reload) so no requests are dropped. It uses the native OpenTelemetry extension on PHP 8, and falls back to a tracer that also covers PHP 7. If a PHP build isn’t supported, the agent skips it and tells you why. If tracing fails to load, it rolls back.

A PHP container offers an SDK option in Discovered Services. Turn it on and the agent injects the tracer, matches it to the container’s PHP build, and reloads the web server (Apache graceful or php-fpm) with no redeploy and no container restart. The instrumented application sends traces to the agent through the container’s host gateway.

This SDK option is on by default in Docker mode. On a Linux host agent it’s opt-in: set KM_CONTAINER_INSTRUMENT_ENABLED=true. To instrument PHP containers automatically without picking each one, use KM_CONTAINER_INSTRUMENT_ALL, KM_CONTAINER_INSTRUMENT_NAMES, or KM_CONTAINER_INSTRUMENT_IMAGES.

The built-in PHP server (php -S) and Alpine (musl) images aren’t supported: the built-in server has no graceful reload, and the bundled tracer assets target glibc. For the details, including the PHP 7 build-time recipe, see Docker platform notes.

On Kubernetes, PHP is covered by eBPF monitoring, not SDK injection, because there’s no OpenTelemetry Operator injector for PHP. Select eBPF for the workload to get HTTP server traces, RED metrics, and the service map from the kernel, with no code change.