From 93fcfac51d05fa9124fba938aba89226fa7bf4e7 Mon Sep 17 00:00:00 2001 From: Jakub Pastuszek Date: Thu, 28 Nov 2024 10:15:09 +0100 Subject: [PATCH] Redis - Metrics collection should not write anything Signed-off-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;