PromPHP / prometheus_client_php

Prometheus instrumentation library for PHP applications
https://prometheus.io/docs/concepts/metric_types/
Apache License 2.0
423 stars 93 forks source link

Validation values #85

Open ShipilovDG opened 2 years ago

ShipilovDG commented 2 years ago

https://github.com/PromPHP/prometheus_client_php/blob/cb7ee990c1a7ca1f8553c531959d13b1450f9f20/src/Prometheus/Storage/APCng.php#L754

if some of $values will be numeric, like status code for example, then it will not work with "false !== ($value = apcu_fetch($key))", because json_encode will return different strings to base64encoder.

i tried this and it works, but i guess it's bad solution. Hope i helped with something.

    //status code to int from string
    if(isset($values[1])){
        $mayBeStatusCode = $values[1];
        $values[1] = is_numeric($mayBeStatusCode) ? (int) $mayBeStatusCode : $mayBeStatusCode;
    }
ShipilovDG commented 2 years ago

@LKaemmerling