Skip to content

Float locale issues #43

@ns3777k

Description

@ns3777k

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions