We’re excited to introduce the first alpha release of Elastic Distribution for OpenTelemetry PHP. In this post, you’ll learn how to easily install and set up monitoring for your PHP applications.
Background
Elastic is standardizing on OpenTelemetry (OTel) for observability and security data collection. As part of that effort, we are providing distributions of the OpenTelemetry Language SDKs. Our Android and iOS SDKs have been OpenTelemetry-based from the start, and we have recently released alpha distributions for Java, .NET, Node.js and Python. The Elastic distribution of OpenTelemetry PHP is the latest addition.
Getting started
To install Elastic Distribution for OpenTelemetry PHP for your application, download the appropriate package for your Linux distribution from https://github.com/elastic/elastic-otel-php/releases.
Currently, we support packages for systems using DEB and RPM package managers for x86_64 and ARM64 processors.
For DEB-based systems, run the following command:
dpkg -i <package-file>.deb
For RPM-based systems, run the following command:
rpm -ivh <package-file>.rpm
For APK-based systems (Alpine), run the following command:
apk add --allow-untrusted <package-file>.apk
The package installer will automatically detect the installed PHP versions and update the configuration, so monitoring extension will be available with the next process restart (you need to restart the processes to load the new php.ini configuration). Some environment variables are needed to provide the necessary configuration for instrumenting your services. These mainly concern the destination of your traces and the identification of your service. You’ll also need to provide the authorization headers for authentication with Elastic Observability Cloud and the Elastic Cloud endpoint where the data is sent.
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=<url encoded apikey header value>"
export OTEL_EXPORTER_OTLP_ENDPOINT=<your elastic cloud url>
where
- OTEL_EXPORTER_OTLP_ENDPOINT: The full URL of the endpoint where data will be sent.
- OTEL_EXPORTER_OTLP_HEADERS: A comma-separated list ofkey=valuepairs that will be added to the headers of every request. This is typically used for authentication information.
After restarting the application, as a result, you should see insights into the monitored applications in Kibana, such as service maps and trace views. In the example below, you can see trace details from the Aimeos application created using the Laravel framework.
Below is an example of a Slim application using HttpAsyncClient:
What's next?
In this alpha version, we support all modern PHP versions from 8.0 to 8.3 inclusive, providing instrumentation for PHP code, including popular frameworks like Laravel, Slim, and HttpAsyncClient, as well as native extensions such as PDO. In future releases, we plan to introduce additional features supported by OpenTelemetry, along with Elastic APM-exclusive features like Inferred Spans.
Stay tuned!
Elastic is committed to helping OpenTelemetry succeed and to helping our customers use OpenTelemetry effectively in their systems. Last year, we donated ECS and continue to work on integrating it with OpenTelemetry Semantic Conventions. More recently, we are working on donating our eBPF-based profiler to OpenTelemetry. We contribute to many of the language SDKs and other OpenTelemetry projects.
As authors of the PHP distribution, we are excited to work with the OpenTelemetry PHP community and to help make the PHP SDK a more robust, featureful, and obvious choice for PHP observability. Having a distro gives us the flexibility to build features on top of the vanilla OTel SDK. Currently, some advantages of the distro include: fully automatic installation and full auto-instrumentation. We will certainly contribute features upstream to the OTel PHP project when possible and will include additional features in the distro when it makes more sense for them to be there.
The Elastic OpenTelemetry Distribution of PHP is currently an alpha. Please try it out and let us know if it might work for you. Watch for the latest releases here. You can engage with us on the project issue tracker or Elastic's PHP APM Discuss forum.
The release and timing of any features or functionality described in this post remain at Elastic's sole discretion. Any features or functionality not currently available may not be delivered on time or at all.