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.

Get the Observe Agent

Use the Add Data portal in the product to get the Observe Agent installed in your environment.

  1. From the left navigation rail, select Data & integrations > Add data.
  2. In the Observe Agent section, pick your environment, then follow the instructions to create a data ingest token and install the Observe Agent.

Depending on the environment you select, you are asked to select some options for installing and configuring the Observe Agent.

Customize your Observe Agent installation in Kubernetes with the following options:

  • Decide what data you want to collect: logs and/or metrics.
  • Whether or not to enable fleet monitoring.
  • Specify the environment value (deployment.environment.name) to enable usage and cost breakdowns.
  1. Follow the remainder of the instructions to install the Observe Agent and verify that your data is being received.

After the Observe Agent is installed, you can Instrument your PHP application.

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

Next steps

Navigate to Traces in your Observe tenant to view traces from your application.