Enabling the PHP Profiler

Requirements

The Datadog Profiler requires at least PHP 7.1, on 64-bit Linux.

The following are not supported:

  • PHP ZTS builds
  • PHP debug builds
  • Fibers (PHP 8.1+)

An operating system with glibc 2.17 or newer is required. The following versions or newer meet this requirement:

  • CentOS 7.
  • Debian 8, which has reached end of life (EOL).
  • Ubuntu 14.04, which is EOL.

Datadog recommends running an OS version that is not EOL.

Version 3.13 or newer of Alpine Linux is required because the profiler is built against musl v1.2.

Continuous Profiler is not supported on serverless platforms, such as AWS Lambda.

Installation

To begin profiling applications:

  1. If you are already using Datadog, upgrade your Agent to version 7.20.2+ or 6.20.2+.

  2. Download the datadog-setup.php script from the GitHub release page. Version 0.69.0 is the first tracer release to include this installer.

  3. Run the installer to install both the tracer and profiler, for example php datadog-setup.php --enable-profiling. This script is interactive and asks which of the detected PHP locations it should install to. At the end of the script, it outputs the non-interactive version of the command arguments for future use.

  4. Configure the profiler with environment variables. Unlike the tracer the profiler does not support INI settings.

    Set the environment variables before calling PHP, for example:

    export DD_PROFILING_ENABLED=true
    export DD_SERVICE=app-name
    export DD_ENV=prod
    export DD_VERSION=1.3.2
    
    php hello.php
    

    Use the env directive in the php-fpm’s www.conf file, for example:

    env[DD_PROFILING_ENABLED] = true
    env[DD_SERVICE] = app-name
    env[DD_ENV] = prod
    env[DD_VERSION] = 1.3.2
    

    Use SetEnv from the server config, virtual host, directory, or .htaccess file:

    SetEnv DD_PROFILING_ENABLED true
    SetEnv DD_SERVICE app-name
    SetEnv DD_ENV prod
    SetEnv DD_VERSION 1.3.2
    

    See the configuration docs for more environment variables.

  5. A minute or two after receiving a request, profiles appear on the APM > Profiler page.

Not sure what to do next?

The Getting Started with Profiler guide takes a sample service with a performance problem and shows you how to use Continuous Profiler to understand and fix the problem.

Further Reading