Error in APM PHP agent

Kibana version: 7.11.1

Elasticsearch version: 7.11.1

APM Server version: 7.11.1

APM Agent language and version: PHP 1.0 beta

Browser version: N/A, but Firefox 86.0

Original install method (e.g. download page, yum, deb, from source, etc.) and version: dpkg

Fresh install or upgraded from other version? fresh

Is there anything special in your setup?

Not that i can think of. I'm using PHP 7.4 FPM and CLI. Here are the relevant php.ini entries:

extension=/opt/elastic/apm-agent-php/extensions/elastic_apm-20190902.so
elastic_apm.bootstrap_php_part_file=/opt/elastic/apm-agent-php/src/bootstrap_php_part.php
elastic_apm.server_url=http://<redacted>:8200
elastic_apm.service_name="Nextcloud"

Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):

APM runs fine for a few minutes, then an error sequence appears repeatedly in logs (see below).

Configuration is Nextcloud running on Apache 2 with PHP 7.4 FPM. Stack otherwise runs fine.

Steps to reproduce:

  1. add agent extension to php.ini file
  2. restart php7.4-fpm service
  3. wait a few minutes, then exercise website

Errors in browser console (if relevant): none

Provide logs and/or server output (if relevant):

   12:03:56.142

    apache.error

    [apache][error] AH01071: Got error 'PHP message: PHP Notice: Undefined variable: _SERVER in /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php on line 98'

    12:04:06.000

    system.syslog

    Elastic APM PHP Tracer [PID: 8217] 2021-03-02 12:04:06.124424-05:00 [CRITICAL] [Bootstrap] [BootstrapStageLogger.php:91] [bootstrap] One of the steps in bootstrap sequence let a throwable escape. TypeError: Argument 2 passed to Elastic\Apm\Impl\Util\ArrayUtil::getValueIfKeyExistsElse() must be of the type array, null given, called in /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php on line 98#012Stack trace:#012#0 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php(98): Elastic\Apm\Impl\Util\ArrayUtil::getValueIfKeyExistsElse()#012#1 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php(46): Elastic\Apm\Impl\AutoInstrument\TransactionForExtensionRequest->discoverHttpName()#012#2 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/TransactionForExtensionRequest.php(41): Elastic\Apm\Impl\AutoInstrument\TransactionForExtensionRequest->beginTransaction()#012#3 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/PhpPartFacade.php(52): Elastic\Apm\Impl\AutoInstrument\TransactionForExtensionRequest->__construct()#012#4 /opt/elastic/apm-agent-php/src/ElasticApm/Impl/AutoInstrument/PhpPartFacade.php(86): Elastic\Apm\Impl\AutoInstrument\PhpPartFacade->__construct()#012#5 [internal function]: Elastic\Apm\Impl\AutoInstrument\PhpPartFacade::bootstrap()#012#6 {main}

    12:04:06.000

    system.syslog

    Elastic APM PHP Tracer [PID: 8217] 2021-03-02 12:04:06.125019-05:00 [CRITICAL] [C-to-PHP] [tracer_PHP_part.c:62] [bootstrapTracerPhpPart] \Elastic\Apm\Impl\AutoInstrument\PhpPartFacade::bootstrap failed (returned false). See log for more details.

    12:04:06.000

    system.syslog

    Elastic APM PHP Tracer [PID: 8217] 2021-03-02 12:04:06.154411-05:00 [NOTICE] [Bootstrap] [BootstrapStageLogger.php:158] [shutdown] Shutdown sequence is invoked even though singleton instance is not created (probably because bootstrap sequence failed)

Hi @rgb3 - welcome to the forum!

It seems the issue is the same one as the one here. Can you please try the workaround proposed at https://odd.blog/2015/02/12/php-notice-undefined-variable-_server-in/ (which is setting auto_globals_jit to off in php.ini)?

Hi, Sergey, thanks for the welcome and the tip! Seems to have worked so far. Will keep this channel posted.

Thanks!