Send PHP application data to Observe

This page describes how to install the Observe Agent, then instrument your PHP applications to send data to Observe.

To view the list of auto-instrumented libraries, see Instrumentation for PHP in the OpenTelemetry documentation on GitHub.

To manually instrument custom logic, see Instrumentation for PHP in the OpenTelemetry documentation.

Instrument your PHP application

Perform the following steps:

  1. Follow the steps in Install the OpenTelemetry extension in the OpenTelemetry documentation to install the required operating system and PECL packages.

  2. Import the libraries.

    1. Use the following commands for regular PHP apps:

    composer require \
        open-telemetry/sdk \
        open-telemetry/exporter-otlp \
        open-telemetry/opentelemetry-auto-slim \
        open-telemetry/opentelemetry-auto-psr18
    
    1. Use the following commands for Wordpress apps:

    composer require \
        open-telemetry/sdk \
        open-telemetry/exporter-otlp \ 
        open-telemetry/opentelemetry-auto-wordpress
    
  3. Set the following environment variables. Replace the placeholders such as ${YOUR_SERVICE_NAME} with the actual information from your environment.

    OTEL_SERVICE_NAME=${YOUR_SERVICE_NAME}
    OTEL_RESOURCE_ATTRIBUTES=deployment.environment=${YOUR_APP_ENVIRONMENT}
    OTEL_EXPORTER_OTLP_ENDPOINT=http://${YOUR_OBSERVE_AGENT_ENDPOINT}:4318 
    OTEL_TRACES_EXPORTER=otlp
    OTEL_METRICS_EXPORTER=otlp
    OTEL_LOGS_EXPORTER=otlp 
    OTEL_PHP_AUTOLOAD_ENABLED=true