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.

Additionally you need to install libgcc_s with:

apk add libgcc

The following profiling features are available in the following minimum versions of the dd-trace-php library:

FeatureRequired dd-trace-php version
Code Hotspots0.71+
Endpoint Profiling0.79.0+

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.

    Set the environment variables before calling PHP, for example:

    # DD_PROFILING_ENABLED is not required for v0.82.0+.
    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:

    ; DD_PROFILING_ENABLED is not required for v0.82.0+
    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:

    # DD_PROFILING_ENABLED is not required for v0.82.0+.
    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.

  4. 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