ENV config should precede over ini config
I have a default config for .ini files but I can't overwrite them with ENV config. Seems like the configuration first looks in ini file and if it exists returns the value.
The c php extension and the php library should look first in ENV vars
I created a test in c (I don't know how to solve it):
--TEST--
Env configuration should precede ini configuration
--SKIPIF--
<?php if ( ! extension_loaded( 'elastic_apm' ) ) die( 'skip'.'Extension elastic_apm must be installed' ); ?>
--ENV--
ELASTIC_APM_ENABLED=true
--INI--
elastic_apm.enabled=false
--FILE--
<?php
declare(strict_types=1);
require __DIR__ . '/../tests_util/tests_util.php';
elasticApmAssertSame("getenv('ELASTIC_APM_ENABLED')", getenv('ELASTIC_APM_ENABLED'), 'true');
elasticApmAssertEqual("ini_get('elastic_apm.enabled')", ini_get('elastic_apm.enabled'), false);
elasticApmAssertSame("elastic_apm_is_enabled()", elastic_apm_is_enabled(), true);
echo 'Test completed'
?>
--EXPECT--
Test completed
And for php, I don't know how to create the test but the TracerBuilder] sets the values of INI and ENV
https://github.com/elastic/apm-agent-php/blob/a457869b0c15e95b61a41bd75da7208a64b18c94/src/ElasticApm/Impl/TracerBuilder.php#L109-L114
So if the config is in the INI won't look at ENV
https://github.com/elastic/apm-agent-php/blob/a457869b0c15e95b61a41bd75da7208a64b18c94/src/ElasticApm/Impl/Config/CompositeRawSnapshot.php#L46-L50
Seems like the solution is change the order.