Skip to content

Commit 381753d

Browse files
pluk77LKaemmerling
andauthored
Prevent php error when data was removed from redis (#149)
This code was already in redis storage but not in redisNg Co-authored-by: Lukas Kämmerling <[email protected]>
1 parent 1d8b02b commit 381753d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Prometheus/Storage/RedisNg.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ private function collectHistograms(): array
415415
$histograms = [];
416416
foreach ($keys as $key) {
417417
$raw = $this->redis->hGetAll(str_replace($this->redis->_prefix(''), '', $key));
418+
if (!isset($raw['__meta'])) {
419+
continue;
420+
}
418421
$histogram = json_decode($raw['__meta'], true);
419422
unset($raw['__meta']);
420423
$histogram['samples'] = [];
@@ -595,6 +598,9 @@ private function collectGauges(bool $sortMetrics = true): array
595598
$gauges = [];
596599
foreach ($keys as $key) {
597600
$raw = $this->redis->hGetAll(str_replace($this->redis->_prefix(''), '', $key));
601+
if (!isset($raw['__meta'])) {
602+
continue;
603+
}
598604
$gauge = json_decode($raw['__meta'], true);
599605
unset($raw['__meta']);
600606
$gauge['samples'] = [];
@@ -632,6 +638,9 @@ private function collectCounters(bool $sortMetrics = true): array
632638
$counters = [];
633639
foreach ($keys as $key) {
634640
$raw = $this->redis->hGetAll(str_replace($this->redis->_prefix(''), '', $key));
641+
if (!isset($raw['__meta'])) {
642+
continue;
643+
}
635644
$counter = json_decode($raw['__meta'], true);
636645
unset($raw['__meta']);
637646
$counter['samples'] = [];

0 commit comments

Comments
 (0)