dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

[BUG] enabling ddtrace extension app starts return empty 200 responses

Open ogidimitrov opened this issue 3 years ago • 15 comments

Bug description

When installing ddtrace php extension via php script provider by datadog, apk or via source to our laravel app and enabling it the app start returning 200 empty responses

PHP version

PHP 7.4.29 (cli) (built: Apr 21 2022 10:16:17) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.29, Copyright (c), by Zend Technologies

Tracer version

bash-5.0# cd /home/jiminny && php artisan tinker Psy Shell v0.10.3 (PHP 7.4.9 — cli) by Justin Hileman

phpversion('ddtrace') => "0.75.0"

bash-5.0#

Installed extensions

[PHP Modules] calendar Core ctype curl date dom exif FFI fileinfo filter ftp gettext gmp hash iconv igbinary intl json libxml mbstring mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline redis Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl Zend OPcache zlib

[Zend Modules] Zend OPcache

OS info

NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)" PRETTY_NAME="Ubuntu 18.04.5 LTS" VERSION_ID="18.04" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic

Diagnostics and configuration

Output of phpinfo() (ddtrace >= 0.47.0)

{"date":"2022-07-08T11:38:29Z","os_name":"Linux 95ffa11053f0 5.4.0-1037-aws #39~18.04.1-Ubuntu SMP Fri Jan 15 02:48:42 UTC 2021 x86_64","os_version":"5.4.0-1037-aws","version":"0.61.0","lang":"php","lang_version":"7.4.9","env":null,"enabled":true,"service":null,"enabled_cli":false,"agent_url":"http://172.17.42.1:8126","debug":false,"analytics_enabled":false,"sample_rate":1.000000,"sampling_rules":null,"tags":null,"service_mapping":null,"distributed_tracing_enabled":true,"priority_sampling_enabled":true,"dd_version":null,"architecture":"x86_64","sapi":"cli","ddtrace.request_init_hook":"/usr/src/php/ext/ddtrace/bridge/dd_wrap_autoloader.php","open_basedir_configured":false,"uri_fragment_regex":null,"uri_mapping_incoming":null,"uri_mapping_outgoing":null,"auto_flush_enabled":false,"generate_root_span":true,"http_client_split_by_domain":false,"measure_compile_time":true,"report_hostname_on_root_span":false,"traced_internal_functions":null,"auto_prepend_file_configured":false,"integrations_disabled":null,"enabled_from_env":true,"opcache.file_cache":null}
bash-5.0# php --ri=ddtrace

ddtrace


Datadog PHP tracer extension
For help, check out the documentation at https://docs.datadoghq.com/tracing/languages/php/
(c) Datadog 2020

Datadog tracing support => enabled
Version => 0.61.0
DATADOG TRACER CONFIGURATION => {"date":"2022-07-08T11:41:26Z","os_name":"Linux 95ffa11053f0 5.4.0-1037-aws #39~18.04.1-Ubuntu SMP Fri Jan 15 02:48:42 UTC 2021 x86_64","os_version":"5.4.0-1037-aws","version":"0.61.0","lang":"php","lang_version":"7.4.9","env":null,"enabled":true,"service":null,"enabled_cli":false,"agent_url":"http://172.17.42.1:8126","debug":false,"analytics_enabled":false,"sample_rate":1.000000,"sampling_rules":null,"tags":null,"service_mapping":null,"distributed_tracing_enabled":true,"priority_sampling_enabled":true,"dd_version":null,"architecture":"x86_64","sapi":"cli","ddtrace.request_init_hook":"/usr/src/php/ext/ddtrace/bridge/dd_wrap_autoloader.php","open_basedir_configured":false,"uri_fragment_regex":null,"uri_mapping_incoming":null,"uri_mapping_outgoing":null,"auto_flush_enabled":false,"generate_root_span":true,"http_client_split_by_domain":false,"measure_compile_time":true,"report_hostname_on_root_span":false,"traced_internal_functions":null,"auto_prepend_file_configured":false,"integrations_disabled":null,"enabled_from_env":true,"opcache.file_cache":null}

                               Diagnostics
Diagnostic checks => passed

Directive => Local Value => Master Value
ddtrace.disable => Off => Off
ddtrace.request_init_hook => /usr/src/php/ext/ddtrace/bridge/dd_wrap_autoloader.php => /usr/src/php/ext/ddtrace/bridge/dd_wrap_autoloader.php
ddtrace.cgroup_file => /proc/self/cgroup => /proc/self/cgroup
bash-5.0#

Output of dd-doctor (ddtrace < 0.47.0)

Upgrading info

from 0.47.1 yet now not working on that version too.

ogidimitrov avatar Jul 08 '22 11:07 ogidimitrov

Did you notice any specific message logged? Could you try with DD_TRACE_DEBUG=1 if you notice anything specific?

labbati avatar Jul 08 '22 13:07 labbati

@labbati i will try Monday, thank you for the quick response.

ogidimitrov avatar Jul 08 '22 17:07 ogidimitrov

@labbati no difference i notice under the agent nothing is actually received by the agent image

ogidimitrov avatar Jul 12 '22 05:07 ogidimitrov

bash-5.0# php a.php
{
  "args": {},
  "data": "",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Host": "httpbin.org",
    "X-Amzn-Trace-Id": "Root=1-62cd19a4-0e16962a63aedbe9059bb714"
  },
  "origin": "52.15.181.124",
  "url": "https://httpbin.org/delay/1"
}
bash-5.0#  export DD_TRACE_ENABLED=1
bash-5.0# export DD_TRACE_CLI_ENABLED=1
bash-5.0# export DD_TRACE_DEBUG=1
bash-5.0# php a.php
bash-5.0# php -v
PHP 7.4.9 (cli) (built: Feb 18 2022 10:20:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.9, Copyright (c), by Zend Technologies
    with ddtrace v0.61.0, Copyright Datadog, by Datadog
bash-5.0# php -m | grep ddtrace
ddtrace
ddtrace
bash-5.0# cd /home/jiminny && php artisan tinker
bash-5.0# export DD_TRACE_CLI_ENABLED=0
bash-5.0# cd /home/jiminny && php artisan tinker
Psy Shell v0.10.3 (PHP 7.4.9 — cli) by Justin Hileman
>>> phpversion('ddtrace')
=> "0.61.0"
>>> die()
Exit:  Goodbye
bash-5.0# cat /tmp/a.php
<?php

sleep(1);

$ch = curl_init('https://httpbin.org/delay/1');
curl_exec($ch);

sleep(1);
bash-5.0#

This test shows php CLI not able to execute a simple php file or laravel artisan when extension enabled

ogidimitrov avatar Jul 12 '22 06:07 ogidimitrov

Hey @ogidimitrov,

Are you trying out multiple different versions? Ideally you check with version 0.76.0; 0.61.0 is already over a year old. At least trying with 0.76.0 I cannot reproduce any such issue locally. (php artisan tinker works perfectly fine for me)

Regarding your a.php, it seems to just do a http request, but I see nothing in that file which should dump curl information. I.e. an empty output is expected (with and without ddtrace). Do you have some extension or tooling which dumps curl requests in PHP?

bwoebi avatar Jul 12 '22 13:07 bwoebi

I have tried 0.75.0, same. As you can see the whole execution fails without a message, like do.. nothing. Can you try simulate the effect on your screen? I will make and share additional tests

ogidimitrov avatar Jul 12 '22 17:07 ogidimitrov

I see proper output, just like I'd expect to see. Hence, I am suspecting something about your environment differing from mine. I just have no idea what exactly. (some extension, some automatically loaded script, ... or really anything)

bwoebi avatar Jul 12 '22 21:07 bwoebi

@bwoebi as i said even simple line is affected using v0.61.0 image

ogidimitrov avatar Jul 13 '22 04:07 ogidimitrov

@bwoebi actually using latest version installed via datadog-setup.php having some progress image

ogidimitrov avatar Jul 13 '22 04:07 ogidimitrov

actually for the run-time php-fpm environment we set these

   export DD_TRACE_ENABLED=true
   export DD_TRACE_CLI_ENABLED=true

could this be related to the problem? i have a PR jiminny side set =1 as the datadog documentation saying, i am not sure was there legacy version supposed to work with that environment variables set to =true ?

ogidimitrov avatar Jul 13 '22 06:07 ogidimitrov

I can confirm there is issue with v0.61.0 image

and i see improvement for 0.76.0 image

ogidimitrov avatar Jul 13 '22 07:07 ogidimitrov

maybe its for separate issue but do Datadog php installer script currently support detecting ARM because i don't see it. I see this:

image

ogidimitrov avatar Jul 13 '22 07:07 ogidimitrov

No, arm is currently not an officially supported target (we're working on it). If you want to, you can compile it yourself though (https://github.com/DataDog/dd-trace-php/issues/1252#issuecomment-930050973).

So, you're saying with 0.76.0 it works? Then there's probably not much we can do here except recommending 0.76.0 to you :-)

bwoebi avatar Jul 13 '22 10:07 bwoebi

Guys, can you advice why this simple make does not work for version 0.76.0 ?

./configure --enable-ddtrace
make
make install

echo -e "extension=ddtrace.so\n\n" > "${PHP_INI_DIR}/conf.d/ddtrace.ini"; \
echo -e "ddtrace.request_init_hook=/usr/src/php/ext/ddtrace/bridge/dd_wrap_autoloader.php\n\n" >> "${PHP_INI_DIR}/conf.d/ddtrace.ini"; \

when tested results this behaviour: image

it works via datadog php install script

image

ogidimitrov avatar Jul 14 '22 10:07 ogidimitrov

For me it also works perfectly when compiling manually from source with the steps you outline. Do you have by chance a complete dockerfile where I can reproduce the issue?

bwoebi avatar Jul 14 '22 10:07 bwoebi

It's been more than a month and we haven't received further feedback. It looks as if the issue that was originally being experienced was fixed with an upgrade of the tracer, tangentially there may have been an issue with arm64 (possibly while trying to debug the problem yourself).

Since there seems to be no more need for support, I'm closing the issue. If I'm wrong about that, please open a new issue.

krakjoe avatar Aug 25 '22 14:08 krakjoe

this got fixed by upgrading to latest version and replace compilation with package install

ogidimitrov avatar Aug 25 '22 15:08 ogidimitrov