ElasticAPM SaaS: PHP agent fails to run

I configured Elastic APM agent using Elastic manual: Set up the Agent | APM PHP Agent Reference [1.x] | Elastic

I configured PHP 7.4 to use elastic_apm.so and restarted PHP-FPM. It fails on every start/connectoin:

-- A start job for unit php-7.4-fpm.service has finished successfully.
-- 
-- The job identifier is 420341.
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646271+00:00 [PID: 20482] [TID: 20482] [ERROR]    [Util] [util_for_PHP.c:50] [loadPhpFile] php_stream_open_for_zend_ex failed. Return value: -1. filename: /root/eapmsrc/apm-agent-php-1.4.2/src/bootstrap_php_part.php
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646396+00:00 [PID: 20482] [TID: 20482] [ERROR]    [Util] [util_for_PHP.c:95] [loadPhpFile] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646417+00:00 [PID: 20482] [TID: 20482] [ERROR]    [C-to-PHP] [tracer_PHP_part.c:81] [bootstrapTracerPhpPart] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.646434+00:00 [PID: 20482] [TID: 20482] [ERROR]    [Lifecycle] [lifecycle.c:472] [elasticApmRequestInit] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.677241+00:00 [PID: 20482] [TID: 20482] [ERROR]    [Util] [util_for_PHP.c:142] [callPhpFunction] call_user_function failed. Return value: -1. PHP function name: `\Elastic\Apm\Impl\AutoInstrument\PhpPartFacade::shutdown'. argsCount: 0.
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.677319+00:00 [PID: 20482] [TID: 20482] [ERROR]    [Util] [util_for_PHP.c:154] [callPhpFunction] Exiting...; resultCode: resultFailure (4);
May 15 16:24:02 dev-wordpress-epuff-it-vm [20482]: [Elastic APM PHP Tracer] 2022-05-15 16:24:02.677354+00:00 [PID: 20482] [TID: 20482] [ERROR]    [C-to-PHP] [tracer_PHP_part.c:112] [shutdownTracerPhpPart] Exiting...; resultCode: resultFailure (4);
^C

Hi Aleksey,

Is it possible that the user under which application is running doesn't have permissions to access /root/eapmsrc/? If you would like to make sure that is the root cause I've added diagnostics for the agent to log when php_stream_open_for_zend_ex fails. Then changes are already merged to the main branch but it's not released yet but you can use the temporary binaries generated by CI.

If the root causes is indeed the permissions I would advise to copy /root/eapmsrc/ somewhere where any user has read access (don't forget to change elastic_apm.bootstrap_php_part_file configuration setting to point to the new location).

1 Like

@Sergey_Kleyman thank you. It seems to be real cause. I moved files to web root and APM started work.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.