Docs » Supported integrations in Splunk Observability Cloud » Instrument back-end applications to send spans to Splunk APM » Instrument PHP applications for Splunk Observability Cloud » Instrument your PHP application for Splunk Observability Cloud

Instrument your PHP application for Splunk Observability Cloud πŸ”—

The OpenTelemetry PHP extension automatically instruments PHP applications using a PHP extension and available instrumentation libraries. You can send telemetry to the Splunk Distribution of OpenTelemetry Collector or directly to the Splunk Observability Cloud ingest endpoint.

To get started, use the guided setup or follow the instructions to install manually.

Generate customized instructions using the guided setup πŸ”—

To generate all the basic installation commands for your environment and application, use the PHP OpenTelemetry guided setup. To access the PHP OpenTelemetry guided setup, follow these steps:

  1. Log in to Splunk Observability Cloud.

  2. Open the PHP OpenTelemetry guided setup . Optionally, you can navigate to the guided setup on your own:

    1. In the navigation menu, select Data Management.

    2. Go to the Available integrations tab, or select Add Integration in the Deployed integrations tab.

    3. In the integration filter menu, select By Product.

    4. Select the APM product.

    5. Select the PHP (OpenTelemetry) tile to open the PHP OpenTelemetry guided setup.

Install the Splunk Distribution of OpenTelemetry PHP manually πŸ”—

If you don’t use the guided setup, follow these steps to manually install and automatically instrument your PHP application:

  1. Check that you meet the requirements. See OpenTelemetry PHP instrumentation compatibility and requirements.

  2. Install the OpenTelemetry PHP extension using PECL in the command line:

    sudo apt-get install gcc make autoconf
    pecl install opentelemetry
    
  3. Add the extension to your php.ini file:

    [opentelemetry]
    extension=opentelemetry.so
    
  4. Install the required instrumentations you need using Composer:

    php composer.phar install open-telemetry/exporter-otlp:^1.0.3
    php composer.phar install php-http/guzzle7-adapter:^1.0
    

    You can also install additional instrumentations. See Supported libraries and frameworks.

  5. Configure the basic settings in your php.ini file or using environment variables:

    OTEL_PHP_AUTOLOAD_ENABLED=true \
    OTEL_SERVICE_NAME="<your-service-name>" \
    OTEL_RESOURCE_ATTRIBUTES="deployment.environment=<your_env>" \
    
  6. Run your application.

    See the OpenTelemetry PHP examples in GitHub for sample instrumentation scenarios.

To configure the instrumentation, see Instrumentation settings.

Connect RUM to APM through server trace data πŸ”—

To connect Real User Monitoring (RUM) requests from mobile and web applications with server trace data, add the OpenTelemetry server timing propagator as a dependency:

php composer.phar install open-telemetry/opentelemetry-propagation-server-timing:^0.0.2

Send data directly to Splunk Observability Cloud πŸ”—

By default, all telemetry is sent to the local instance of the Splunk Distribution of OpenTelemetry Collector.

To bypass the Collector and send data directly to Splunk Observability Cloud, set the following environment variables:

OTEL_EXPORTER_OTLP_TRACES_HEADERS=x-sf-token=<access_token>
OTEL_EXPORTER_OTLP_ENDPOINT=https://ingest.<realm>.signalfx.com/trace/otlp

To obtain an access token, see Retrieve and manage user API access tokens using Splunk Observability Cloud.

To find your Splunk realm, see Note about realms.

Instrumentation settings πŸ”—

You can configure the OpenTelemetry PHP extension using the following settings.

General settings πŸ”—

Exporter settings πŸ”—

Instrumentation settings πŸ”—

This page was last updated on May 14, 2024.