Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

How to install & Configure Datadog APM with PHP based application (WordPress) in linux?

Prerequisite

Step 1- Install DD Agent and Start it

Step 2- Choose your language- Offcourse PHP

Step 3- Install the PHP client for APM datadog tracing

Reference:
- https://github.com/DataDog/dd-trace-php/releases

$ cd /opt
$ wget https://github.com/DataDog/dd-trace-php/releases/download/0.53.0/datadog-php-tracer-0.53.0-1.x86_64.rpm
$ rpm -ivh datadog-php-tracer-0.53.0-1.x86_64.rpm

Step 4 – Make sure following Spec to avoid an ERROR

$ vi /opt/lampp/etc/php.ini
extension=/opt/datadog-php/extensions/ddtrace-.so - WRONG

$ more /opt/lampp/logs/php_error_log

# Take latest version of ddtrace using "ls /opt/datadog-php/extensions/"
$ vi /opt/lampp/etc/php.ini
extension=/opt/datadog-php/extensions/ddtrace-20200930.so - RIGHT

$ /opt/lampp/lampp restart

Step 5 – Validate ddtrace is enabled or not

$ export PATH=$PATH:/opt/lampp/bin/
$ php --version
$ php -m | grep ddtrace

Step 4 – Modify Apache Configuration to set Datadog APM Meta data for a application

vi /opt/lampp/etc/httpd.conf

SetEnv DD_SERVICE 'wordpress'
SetEnv DD_ENV 'dev'
SetEnv DD_VERSION 'latest'
SetEnv DD_TRACE_SAMPLE_RATE '1'
SetEnv DD_TRACE_DEBUG true

$ /opt/lampp/lampp restart

Step 5 – Create a load on http://13.233.196.197/wordpress/ using Jmeter

$ netstat -tulpn | grep LISTEN
$ curl http://127.0.0.1:8126
$ datadog-agent config | head -n 35

By default the Datadog Agent is enabled in your datadog.yaml file under apm_enabled: true and listens for trace traffic at localhost:8126

Error & Solution – 1

[root@ip-172-31-25-121 opt]# rpm -ivh datadog-php-tracer-0.53.0-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:datadog-php-tracer-0.53.0-1      ################################# [100%]
### PHP version
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
### Installing Datadog PHP tracing extension (ddtrace)
###
### Logging  -i to a file
###
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
###
### conf.d folder not found falling back to appending extension config to main "php.ini"
/var/tmp/rpm-tmp.hSDzSh: line 34: -d: command not found
### Failed enabling ddtrace extension
###
### The extension has been installed but couldn't be enabled
### Try adding the extension manually to your PHP - php.ini - configuration file
### e.g. by adding following line:
###
###     extension=/opt/datadog-php/extensions/ddtrace-.so
###
### Note that your PHP API version must match the extension's API version
### PHP API version can be found using following command
###
###      -i | grep 'PHP API'
###
[root@ip-172-31-25-121 opt]# php
bash: php: command not found

SOLUTION
--------------
rpm -e datadog-php-tracer-0.53.0-1.x86_64
rm -rf datadog-php
export PATH=$PATH:/opt/lampp/bin/
php --version

extension=/opt/datadog-php/extensions/ddtrace-.so

===========================================
DD_TRACE_CLI_ENABLED=true DD_SERVICE='test' DD_ENV='dev' DD_VERSION='1' DD_TRACE_SAMPLE_RATE='1' php -r 'echo "Hello PHP";'
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)