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.

In Docker mode, the agent instruments PHP containers automatically, in place, and matches the container’s PHP build. It reloads the SAPI (Apache graceful or php-fpm) with no redeploy, so this is separate from the Off / eBPF toggle. Narrow or turn it off with the KM_CONTAINER_INSTRUMENT_* environment variables. The instrumented application sends traces to the agent through the container’s host gateway.

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.