diff --git a/php-fpm/www.conf b/php-fpm/www.conf index 1517299e..0c6d16c5 100644 --- a/php-fpm/www.conf +++ b/php-fpm/www.conf @@ -1,7 +1,7 @@ [www] user = www-data group = www-data -listen = 127.0.0.1:9000 +listen = 9000 pm = static pm.max_children = 20 access.format = "%R %p [%t] \"%m %r\" %s %{micro}d %C %M %l" diff --git a/src/Prometheus/Storage/APCng.php b/src/Prometheus/Storage/APCng.php index 1e115fc7..2b689533 100644 --- a/src/Prometheus/Storage/APCng.php +++ b/src/Prometheus/Storage/APCng.php @@ -148,17 +148,17 @@ public function updateSummary(array $data): void // Check if sample counter for this timestamp already exists, so we can deterministically // store observations+counts, one key per second // Atomic increment of the observation counter, or initialize if new - $sampleCount = apcu_fetch($sampleCountKey); - - if ($sampleCount === false) { - $sampleCount = 0; - apcu_add($sampleCountKey, $sampleCount, $data['maxAgeSeconds']); + if (apcu_fetch($sampleCountKey) === false) { + apcu_add($sampleCountKey, 0, $data['maxAgeSeconds']); } - $this->doIncrementKeyWithValue($sampleCountKey, 1); + $sampleCount = apcu_inc($sampleCountKey); + if ($sampleCount === false) { /** @phpstan-ignore-line */ + throw new RuntimeException('Failed to increment summary sample counter'); + } // We now have a deterministic keyname for this observation; let's save the observed value - $sampleKey = $sampleKeyPrefix . '.' . $sampleCount; + $sampleKey = $sampleKeyPrefix . '.' . ($sampleCount - 1); apcu_add($sampleKey, $data['value'], $data['maxAgeSeconds']); }