Dash0 Acquires Lumigo to Expand Agentic Observability Across AWS and Serverless
Observe PHP applications in real-time. Gain insights into your app's performance and identify potential issues proactively.
Instrumenting your PHP application to generate traces, logs, and metrics is a powerful way to gain deep insights into its behavior and performance. For example, to get a clearer picture of your Laravel applications and the database statements generated through Eloquent ORM. By adding instrumentation, you enable your application to emit valuable data that can be used for monitoring, troubleshooting, and optimization.
Dash0 supports automatic instrumentation of PHP applications through OpenTelemetry's open-source and vendor-agnostic packages.
The opentelemetry-php-contrib repository offers a comprehensive set of auto-instrumentation libraries that enable observability for PHP workloads without requiring any application code changes.
This guide demonstrates how to instrument a PHP application built with the Slim Framework by installing a minimal set of packages and applying the required configuration to enable auto-instrumentation. We also encourage the use of any additional auto-instrumentation libraries relevant to the technologies used in your application, as listed in the repository above.
Within the Instrumentation section of the opentelemetry-php-contrib repository, a wide range of auto-instrumentation libraries is available. In this example, we will utilize the auto-instrumentation for common PHP frameworks and HTTP clients by installing the required OpenTelemetry packages.
1. Install the required packages
These packages provide:
Step 2: Install PHP Extension
To install the required PHP extension, use the appropriate command for your operating system:
Linux (APT-based distributions):
macOS (Homebrew):
After finish the installation by building and installing the PHP extension, run:
Step 3: Run your app with the appropriate otel environment variables
In case you are not using the Dash0 operator for Kubernetes to deploy your application, you should extend the OpenTelemetry resource attributes to include the Pod UID. This is important to merge the resources between logs,traces and metrics. You can do this by adding the following environment variables to your deployment:
This will add the k8s.pod.name and k8s.pod.uid attributes to the OpenTelemetry resource attributes, which will be included in all telemetry data sent to Dash0.
To read more about resource equality and merging, please refer to the Dash0 docs.
In order to learn more about the importance of resource attributes read the blog post OpenTelemetry resource attributes: Best practices for Kubernetes
To see which libraries are automatically instrumented, refer to the OpenTelemetry registry.