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

Rely on bucket count instead of hIncrByFloat return value #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public function updateHistogram(array $data)
unset($metaData['value']);
unset($metaData['labelValues']);
$this->redis->eval(<<<LUA
local increment = redis.call('hIncrByFloat', KEYS[1], KEYS[2], ARGV[1])
redis.call('hIncrBy', KEYS[1], KEYS[3], 1)
if increment == ARGV[1] then
redis.call('hIncrByFloat', KEYS[1], KEYS[2], ARGV[1])
local increment = redis.call('hIncrBy', KEYS[1], KEYS[3], 1)
if increment == 1 then
redis.call('hSet', KEYS[1], '__meta', ARGV[2])
redis.call('sAdd', KEYS[4], KEYS[1])
end
Expand Down
8 changes: 4 additions & 4 deletions tests/Test/Prometheus/AbstractHistogramTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function itShouldObserveValuesOfTypeDouble()
array(),
array(0.1, 0.2, 0.3)
);
$histogram->observe(0.11);
$histogram->observe(1343.11);
$histogram->observe(0.3);
$this->assertThat(
$this->adapter->collect(),
Expand All @@ -200,13 +200,13 @@ public function itShouldObserveValuesOfTypeDouble()
'name' => 'test_some_metric_bucket',
'labelNames' => array('le'),
'labelValues' => array(0.2),
'value' => 1,
'value' => 0,
),
array(
'name' => 'test_some_metric_bucket',
'labelNames' => array('le'),
'labelValues' => array(0.3),
'value' => 2,
'value' => 1,
),
array(
'name' => 'test_some_metric_bucket',
Expand All @@ -224,7 +224,7 @@ public function itShouldObserveValuesOfTypeDouble()
'name' => 'test_some_metric_sum',
'labelNames' => array(),
'labelValues' => array(),
'value' => 0.41,
'value' => 1343.41000000000000003,
)
)
)
Expand Down