Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Handle non-existing histogram keys in redis storage #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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