Skip to content

Commit

Permalink
fix(storage): Fix histogram storage doesn't clear
Browse files Browse the repository at this point in the history
  • Loading branch information
zlodes committed Jul 5, 2023
1 parent 13a1f8b commit 24f0194
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Storage/InMemoryStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function fetch(): Generator
public function clear(): void
{
$this->simpleMetricsStorage = [];
$this->histogramStorage = [];
}

public function setValue(MetricValue $value): void
Expand Down
14 changes: 13 additions & 1 deletion src/Storage/StorageTesting.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,19 @@ public function testGetAllAndEmpty(): void
)
);

assertCount(1, $this->fetchList($storage));
$storage->persistHistogram(
new MetricValue(
new MetricNameWithLabels('response_time'),
0.5
),
[0.1, 0.5, 1]
);

// 1 of cpu_temp gauge
// 3 of response_time histogram
// 1 +Inf of response_time histogram
// 2 (sum and count) of response_time histogram
assertCount(7, $this->fetchList($storage));

$storage->clear();
assertEmpty($this->fetchList($storage));
Expand Down

0 comments on commit 24f0194

Please sign in to comment.