Skip to content
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

Float locale issues #43

Open
ns3777k opened this issue Apr 3, 2020 · 1 comment
Open

Float locale issues #43

ns3777k opened this issue Apr 3, 2020 · 1 comment

Comments

@ns3777k
Copy link

ns3777k commented Apr 3, 2020

Prometheus can only deal with floats written with a dot (2.20 in en_EN for example). However if a project is set to use ru_RU, floats are written with a comma.

<?php
  
setlocale(LC_NUMERIC, 'en_EN');
printf("%f\n", 2.22); // prints 2.220000 which is correct

setlocale(LC_NUMERIC, 'ru_RU');
printf("%f\n", 2.22); // prints 2,220000 which is not correct

This can be fixed dropping the locale to C and returning it back after stringifying. Symfony guys fixed it in the VarDumper component here https://github.com/symfony/symfony/pull/23575/files .

Of course a project can drop locale when rendering the metrics, but IMO this should be handled by the library.

@amfleurke
Copy link

It's not only when rendering.
The APC.php storage handler has a function histogramBucketValueKey that just converts the float to string for naming the buckets, which causes the bucket to not be updated if the float is rendered with comma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants