-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading boolean configuration values via php.ini is impossible due to architecture #1442
Comments
So I did some poking around php internals and available solutions, and it does seem that reimplementation of
It could be fractionally slower than the native function (wasn't in my tests, but in theory it could), but it's specification-friendly, working, and drop-in. I can prepare PR later, please just someone let me know if you like this approach. |
if it's not possible to quote the values in php.ini (eg |
Ok, you got me here :) I was so focused on debugging the issue, I hadn't even consider quoting of this string could be mandatory. I see one drawback of my solution – it won't work with parameters defined by |
Great! We could probably add some phpdoc to the ini processing class, as folks might look there. It's been some time since I went over our documentation over in opentelemetry.io, but it's very briefly mentioned in https://opentelemetry.io/docs/languages/php/sdk/#autoloading and maybe that section could be improved. |
So because my application works with spawning some sub-processes in a manner that doesn't pass full environment verbatim, I've tried to move configuration to php.ini, and it does seem that it's impossible to do so in a consistent way.
The issue is, that some values are boolean:
and php function https://www.php.net/manual/en/function.get-cfg-var.php used in
OpenTelemetry\Config\SDK\Configuration\Environment\PhpIniEnvSource
to read configuration from ini file has some undocumented, but consistent behaviour where any value considered by php developers as a 'truthy' is returned as string of value '1'.The behaviour is apparently consistent between all php versions since at least 2013, probably since forever.
This makes
OpenTelemetry\SDK\Common\Configuration\Parser\BooleanParser
always throwInvalidArgumentException
, as only acceptable values are 'true' and 'false', log warningInvalid boolean value "%s" interpreted as "false" for %s'
, and not enable instrumentation.This, unfortunately makes the php.ini way of configuration mentioned in documentation impossible, and as I can see in git history it was impossible since #870, so for good two years.
I see three ways to fix the issue – either revert the change to allow string
"1"
as a valid boolean value, reimplement php configuration parser to return verbatim configuration variable values, or drop this path of configuration altogether from documentation.FYI @brettmc
The text was updated successfully, but these errors were encountered: