Skip to content

Commit

Permalink
Handle non-existing histogram keys in redis storage
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske authored and LeSuisse committed May 18, 2019
1 parent 547e0bc commit f38b4f5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ public function updateCounter(array $data)
private function collectHistograms()
{
$keys = $this->redis->sMembers(self::$prefix . Histogram::TYPE . self::PROMETHEUS_METRIC_KEYS_SUFFIX);
if ($keys === false) {
return array();
}

sort($keys);
$histograms = array();
foreach ($keys as $key) {
Expand Down Expand Up @@ -278,6 +282,10 @@ private function collectHistograms()
private function collectGauges()
{
$keys = $this->redis->sMembers(self::$prefix . Gauge::TYPE . self::PROMETHEUS_METRIC_KEYS_SUFFIX);
if ($keys === false) {
return array();
}

sort($keys);
$gauges = array();
foreach ($keys as $key) {
Expand All @@ -304,6 +312,10 @@ private function collectGauges()
private function collectCounters()
{
$keys = $this->redis->sMembers(self::$prefix . Counter::TYPE . self::PROMETHEUS_METRIC_KEYS_SUFFIX);
if ($keys === false) {
return array();
}

sort($keys);
$counters = array();
foreach ($keys as $key) {
Expand Down

0 comments on commit f38b4f5

Please sign in to comment.