From d6233ccf60fa6498d70beefc3ecb3c080e5b71e6 Mon Sep 17 00:00:00 2001 From: Jakub Pastuszek Date: Mon, 2 Dec 2024 13:14:55 +0100 Subject: [PATCH] Redis - Metrics collection should not write anything (#165) Signed-off-by: Jakub Pastuszek Co-authored-by: Jakub Pastuszek --- src/Prometheus/Storage/Redis.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 122d11a3..2763565c 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -536,7 +536,11 @@ private function collectSummaries(): array } if (count($samples) === 0) { - $this->redis->del($valueKey); + try { + $this->redis->del($valueKey); + } catch (\RedisException $e) { + // ignore if we can't delete the key + } continue; } @@ -571,7 +575,11 @@ private function collectSummaries(): array if (count($data['samples']) > 0) { $summaries[] = $data; } else { - $this->redis->del($metaKey); + try { + $this->redis->del($metaKey); + } catch (\RedisException $e) { + // ignore if we can't delete the key + } } } return $summaries;