Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward compatiblity with older redis versions #133

Merged
merged 4 commits into from
Nov 6, 2023
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
os: [ ubuntu-latest ]
php: [ 7.4, 8.0, 8.1, 8.2 ]
dependency-version: [ prefer-lowest, prefer-stable ]
redis-version: [ 6 ]
redis-version: [ 5, 6, 7 ]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} - ${{ matrix.redis-version }}

env:
# The hostname used to communicate with the Redis service container
Expand Down
2 changes: 1 addition & 1 deletion src/Prometheus/CollectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function wipeStorage(): void
*/
public function getMetricFamilySamples(bool $sortMetrics = true): array
{
return $this->storageAdapter->collect($sortMetrics);
return $this->storageAdapter->collect($sortMetrics); /** @phpstan-ignore-line */
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Prometheus/Storage/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function wipeStorage(): void

$this->redis->eval(
<<<LUA
redis.replicate_commands()
local cursor = "0"
repeat
local results = redis.call('SCAN', cursor, 'MATCH', ARGV[1])
Expand Down
3 changes: 2 additions & 1 deletion src/Prometheus/Storage/RedisNg.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public function wipeStorage(): void

$this->redis->eval(
<<<LUA
redis.replicate_commands()
local cursor = "0"
repeat
local results = redis.call('SCAN', cursor, 'MATCH', ARGV[1])
Expand Down Expand Up @@ -474,7 +475,7 @@ private function collectHistograms(): array
*
* @return string
*/
private function removePrefixFromKey(string $key): string
private function removePrefixFromKey(string $key): string /** @phpstan-ignore-line */
{
// @phpstan-ignore-next-line false positive, phpstan thinks getOptions returns int
if ($this->redis->getOption(\Redis::OPT_PREFIX) === null) {
Expand Down
8 changes: 4 additions & 4 deletions tests/Test/BlackBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function gaugesShouldBeOverwritten(): void

];

Promise\settle($promises)->wait();
Promise\Utils::settle($promises)->wait();
$end = microtime(true);
echo "\ntime: " . ($end - $start) . "\n";

Expand Down Expand Up @@ -84,7 +84,7 @@ public function countersShouldIncrementAtomically($increment): void
$n += $increment;
}

Promise\settle($promises)->wait();
Promise\Utils::settle($promises)->wait();
$end = microtime(true);
echo "\ntime: " . ($end - $start) . "\n";

Expand Down Expand Up @@ -124,7 +124,7 @@ public function histogramsShouldIncrementAtomically(): void
$this->client->getAsync('/examples/some_histogram.php?c=9&adapter=' . $this->adapter),
];

Promise\settle($promises)->wait();
Promise\Utils::settle($promises)->wait();
$end = microtime(true);
echo "\ntime: " . ($end - $start) . "\n";

Expand Down Expand Up @@ -168,7 +168,7 @@ public function summariesShouldIncrementAtomically(): void
$this->client->getAsync('/examples/some_summary.php?c=10&adapter=' . $this->adapter),
];

Promise\settle($promises)->wait();
Promise\Utils::settle($promises)->wait();
$end = microtime(true);
echo "\ntime: " . ($end - $start) . "\n";

Expand Down
Loading