Loading

Set up EDOT PHP

Elastic Stack Serverless Observability

Learn how to use the Elastic Distribution of OpenTelemetry PHP (EDOT PHP) to instrument your PHP application and send OpenTelemetry data to an Elastic Observability deployment.

Before you begin, make sure you have a destination for the telemetry data collected by EDOT PHP. While EDOT PHP can export data to any OpenTelemetry Protocol (OTLP)–compatible endpoint, this guide focuses on using Elastic Observability as the backend. You can either use an existing Elastic Cloud deployment or create a new one.

To quickly get up and running, follow the Elastic OpenTelemetry Quickstart guide, which walks you through:

  • Creating a free Elastic Cloud deployment.
  • Configuring your OpenTelemetry agent.
  • Exploring traces and metrics in Kibana.

Refer to Supported technologies for details about currently supported operating systems and PHP versions.

Refer to Limitations to learn about the limitations of EDOT PHP.

To install EDOT PHP, download one of the packages for supported platforms.

rpm -ivh <package-file>.rpm
dpkg -i <package-file>.deb
apk add --allow-untrusted <package-file>.apk

After installing EDOT PHP, configure and initialize it to start sending data to Elastic.

To configure EDOT PHP, at a minimum you need your Elastic Observability cloud deployment's OTLP endpoint and authorization data to set a few OTLP_* environment variables that will be available when running EDOT PHP:

  • OTEL_EXPORTER_OTLP_ENDPOINT: The full URL of the endpoint where data will be sent.
  • OTEL_EXPORTER_OTLP_HEADERS: A comma-separated list of key=value pairs that is added to the headers of every request. This is typically used for authentication information.

Here's an example how to connect to Serverless environment:

export OTEL_EXPORTER_OTLP_ENDPOINT=https://my-deployment.ingest.us-west-2.aws.elastic.cloud:443/
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=ApiKey P....=="

After completing the configuration, you should restart the PHP process. If you are using PHP as an Apache Webserver module or PHP-FPM, you need to perform a full process restart to ensure that the extension with the agent is loaded correctly.

To confirm that EDOT PHP has successfully connected to Elastic:

  1. Go to APMTraces in Elastic Observability.
  2. Find the name of the service to which you just added EDOT PHP. It can take several minutes after initializing EDOT PHP for the service to show up in this list.
  3. Select the name in the list to see trace data.
Note

There might be no trace data to visualize unless you have used your application since initializing EDOT PHP.