Learn how to instrument your PHP application with OpenTelemetry PHP Distro and send telemetry data to an OTLP-compatible backend.
- Have a destination for telemetry data (OTLP endpoint).
- Use a supported Linux and PHP version.
- Do not run another PHP APM or OpenTelemetry agent in the same process.
For supported operating systems and PHP versions, see Supported technologies.
Known runtime and compatibility limitations are described in Limitations.
Download a package for your platform from the project releases and install it.
sudo rpm -ivh <package-file>.rpmsudo dpkg -i <package-file>.debsudo apk add --allow-untrusted <package-file>.apkThe distro is also published as an image that holds only its files under /opt/opentelemetry. Add it to your own PHP image with COPY --from. No package manager or install script is involved.
Each image works with every supported PHP version, on linux/amd64 and linux/arm64. Pick the tag by the C library of your base image:
| Base image | Example | Tags |
|---|---|---|
| Debian or Ubuntu (glibc) | php:8.4-fpm |
X.Y.Z, X.Y, latest |
| Alpine (musl) | php:8.4-fpm-alpine |
X.Y.Z-musl, X.Y-musl, musl |
The images are at ghcr.io/open-telemetry/opentelemetry-php-distro. Pin a full version in production. The versions are listed on the releases page.
X.Yfollows the newest patch release of that minor version.latestandmuslfollow the newest release. A patch to an older minor version doesn't move them.- Before 1.0 there is no major-only tag, because a minor release can include breaking changes. From 1.0,
XandX-muslfollow the newest release of that major version. - Pre-releases get only their own version tag.
Copy the files and the ini that loads the extension. Replace <version> with a release version:
FROM php:8.4-fpm
COPY --from=ghcr.io/open-telemetry/opentelemetry-php-distro:<version> /opt/opentelemetry /opt/opentelemetry
COPY --from=ghcr.io/open-telemetry/opentelemetry-php-distro:<version> \
/opt/opentelemetry/php/distro/etc/opentelemetry-distro.ini \
/usr/local/etc/php/conf.d/98-opentelemetry-distro.iniFor Alpine, use the -musl tag:
FROM php:8.4-fpm-alpine
COPY --from=ghcr.io/open-telemetry/opentelemetry-php-distro:<version>-musl /opt/opentelemetry /opt/opentelemetry
COPY --from=ghcr.io/open-telemetry/opentelemetry-php-distro:<version>-musl \
/opt/opentelemetry/php/distro/etc/opentelemetry-distro.ini \
/usr/local/etc/php/conf.d/98-opentelemetry-distro.ini/usr/local/etc/php/conf.d is the scan directory in the official PHP images. For other images, php --ini shows it.
To change settings, add another ini file that sorts after 98-opentelemetry-distro.ini, or set environment variables. See Configuration.
- glibc images need glibc 2.28 or later, the same as the
debandrpmpackages.ldd --versionshows the version. - Thread-safe (ZTS) PHP builds are not supported. The extension logs an error and does nothing. The official
-ztsimages are ZTS builds.
Release images are signed with cosign keyless signing, from the release workflow. To verify a tag:
cosign verify ghcr.io/open-telemetry/opentelemetry-php-distro:<version> \
--certificate-identity-regexp '^https://github\.com/open-telemetry/opentelemetry-php-distro/\.github/workflows/release\.yml@refs/tags/v' \
--certificate-oidc-issuer https://token.actions.githubusercontent.comEach image also carries build provenance and an SBOM. docker buildx imagetools inspect <image> --format '{{json .Provenance}}' shows the provenance, and --format '{{json .SBOM}}' the SBOM.
To build the image from built packages in _BUILT/packages:
./tools/build/build_image.sh --libc glibc --tag opentelemetry-php-distro:local
./tools/build/build_image.sh --libc musl --tag opentelemetry-php-distro:local-muslThen use opentelemetry-php-distro:local or opentelemetry-php-distro:local-musl in the COPY --from lines.
At a minimum, set:
OTEL_EXPORTER_OTLP_ENDPOINTOTEL_EXPORTER_OTLP_HEADERS
Example:
export OTEL_EXPORTER_OTLP_ENDPOINT="https://your-otlp-endpoint:443/"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <token>"After installation and configuration, restart PHP processes (for example php-fpm, Apache workers, or long-running CLI workers) so the extension loads.
- Open your observability backend.
- Find your service in traces.
- Generate traffic if no traces are visible yet.
- Verify configuration options in Configuration.
- Check known constraints in Limitations.
- If using Laravel Octane (Swoole or RoadRunner), see Long-running PHP servers.