prometheus_client_php icon indicating copy to clipboard operation
prometheus_client_php copied to clipboard

APCng crashing when rendering with integer labels

Open seifane-wise opened this issue 1 year ago • 0 comments

It seems that APCng is not handling integers labels very well.

It registers them correctly when incrementing a counter for example :

$counter = $registry->getOrRegisterCounter(..., ["path", "response_code"]);
$counter->incBy(1, ["a/path/", 200]);

This code was working fine under Redis.

However under APCng when rendering the metrics it seems that it is unable to fetch back the label values if they were all integers and this leads to a crash.

ErrorException: Undefined array key 1 in file /code/vendor/promphp/prometheus_client_php/src/Prometheus/Storage/APCng.php on line 443

#0 /code/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Undefined array...', '/code/vendor/pr...', 443)
#1 /code/vendor/promphp/prometheus_client_php/src/Prometheus/Storage/APCng.php(443): Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}(2, 'Undefined array...', '/code/vendor/pr...', 443)
#2 /code/vendor/promphp/prometheus_client_php/src/Prometheus/Storage/APCng.php(563): Prometheus\Storage\APCng->buildPermutationTree(Array, Array)
#3 /code/vendor/promphp/prometheus_client_php/src/Prometheus/Storage/APCng.php(477): Prometheus\Storage\APCng->getValues('counter', Array)
#4 /code/vendor/promphp/prometheus_client_php/src/Prometheus/Storage/APCng.php(80): Prometheus\Storage\APCng->collectCounters(true)
#5 /code/vendor/promphp/prometheus_client_php/src/Prometheus/CollectorRegistry.php(86): Prometheus\Storage\APCng->collect(true)

Happy to give more details to help resolve this if needed.

seifane-wise avatar May 21 '24 06:05 seifane-wise