Jimdo / prometheus_client_php

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

Detect if APC is enabled when trying to use APC storage. #76

Open alex-vlasov opened 6 years ago

alex-vlasov commented 6 years ago

When we use APC storage there's a chance to get infinite loop if APC was disabled by mistake. In particular this is happening when you try to update histogram - https://github.com/Jimdo/prometheus_client_php/blob/master/src/Prometheus/Storage/APC.php#L36:

        $done = false;
        while (!$done) {
            $old = apcu_fetch($sumKey);
            $done = apcu_cas($sumKey, $old, $this->toInteger($this->fromInteger($old) + $data['value']));
        }

To prevent this we can introduce additional check for APC storage.