Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php-fpm/www.conf
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 7 additions & 7 deletions src/Prometheus/Storage/APCng.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

Expand Down
Loading