apm-agent-php icon indicating copy to clipboard operation
apm-agent-php copied to clipboard

[PHP-FPM] apm-agent-php is ignoring all elastic_apm directives inside php-fpm pool configuration

Open reporter4u opened this issue 2 years ago • 2 comments

Describe the bug OS: Centos 7.9 PHP: 7.4.28

In the php-fpm pool configuration (/etc/php-fpm.d/mypoll.conf) I've added these directives:

php_admin_flag[elastic_apm.enabled] = true
php_admin_value[elastic_apm.environment] = "test"
php_admin_value[elastic_apm.log_level] = "INFO"
php_admin_value[elastic_apm.log_level_stderr] = "INFO"
php_admin_value[elastic_apm.server_timeout] = "30s"
php_admin_value[elastic_apm.server_url] = "https://<my_ip>:<my_port>"
php_admin_value[elastic_apm.service_name] = "dev-webfarm-php-comm-portali"
php_admin_value[elastic_apm.transaction_max_spans] = 500
php_admin_value[elastic_apm.transaction_sample_rate] = 1.0
php_admin_flag[elastic_apm.verify_server_cert] = false

In my /etc/php.d/99-elastic-apm-custom.ini link (-> /opt/elastic/apm-agent-php/etc/99-elastic-apm-custom.ini) I've set these two lines:

[elastic]
elastic_apm.enabled = false

What I expect is that the above directive php_admin_flag[elastic_apm.enabled] = true in mypoll.conf file overrides the directive elastic_apm.enabled = false in 99-elastic-apm-custom.ini file and indeed it does but in practice is ignored by the agent as well as all the other directives in mypool.conf file.

As a result the apm-agent-fpm remains disabled and doesn't work. Even if the phpinfo(); function returns all the variables well defined and the elastic_apm.enabled overridden with a true value.

The workaround is as simple as explanatory: renaming (or deleting) the agent custom ini file (es. /opt/elastic/apm-agent-php/etc/99-elastic-apm-custom.NOT) the pool configuration works! Because all elastic_apm directives in /etc/php-fpm.d/mypoll.conf are taken into account

Expected behavior I expect both directives inside /etc/php.d/99-elastic-apm-custom.ini and /etc/php-fpm.d/mypoll.conf files are merged with the priority of those inside pool configuration (mypoll.conf).

It deserves to check if this behavior is affecting also Apache Httpd per virtual host mod_php directives.

reporter4u avatar Apr 07 '22 13:04 reporter4u

I would like to add that with the apm-agent-php per pool configuration, the agent prints the following log also in the other pools where the agent is not activated and configured.

[26-Apr-2022 11:09:06 Europe/Rome] PHP Warning:  Unknown: open_basedir restriction in effect. File(/opt/elastic/apm-agent-php/src/bootstrap_php_part.php) is not within the allowed path(s): (/var/www/mypool) in Unknown on line 0

I think this is another bug related to my previous post in this issue.

Thank you.

reporter4u avatar Apr 26 '22 10:04 reporter4u

I have the same problem using php fpm 8.0.

MajedDH avatar Feb 22 '23 18:02 MajedDH