Skip to content

Commit 6ba18b8

Browse files
committed
fix: bring _prefix() back
Signed-off-by: Mateusz Cholewka <mateusz@cholewka.com.pl>
1 parent 0f0b586 commit 6ba18b8

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/Prometheus/Storage/AbstractRedis.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ protected function collectHistograms(): array
292292
sort($keys);
293293
$histograms = [];
294294
foreach ($keys as $key) {
295-
$raw = $this->redis->hGetAll(ltrim($key, $this->redis->getOption(RedisClient::OPT_PREFIX)));
295+
$raw = $this->redis->hGetAll(ltrim($key, $this->redis->prefix('')));
296296
if (! isset($raw['__meta'])) {
297297
continue;
298298
}
@@ -373,7 +373,7 @@ protected function removePrefixFromKey(string $key): string
373373
return $key;
374374
}
375375

376-
return substr($key, strlen($this->redis->getOption(RedisClient::OPT_PREFIX)));
376+
return substr($key, strlen($this->redis->prefix('')));
377377
}
378378

379379
/**
@@ -483,7 +483,7 @@ protected function collectGauges(bool $sortMetrics = true): array
483483
sort($keys);
484484
$gauges = [];
485485
foreach ($keys as $key) {
486-
$raw = $this->redis->hGetAll(ltrim($key, $this->redis->getOption(RedisClient::OPT_PREFIX)));
486+
$raw = $this->redis->hGetAll(ltrim($key, $this->redis->prefix('')));
487487
if (! isset($raw['__meta'])) {
488488
continue;
489489
}
@@ -525,7 +525,7 @@ protected function collectCounters(bool $sortMetrics = true): array
525525
sort($keys);
526526
$counters = [];
527527
foreach ($keys as $key) {
528-
$raw = $this->redis->hGetAll(ltrim($key, $this->redis->getOption(RedisClient::OPT_PREFIX)));
528+
$raw = $this->redis->hGetAll(ltrim($key, $this->redis->prefix('')));
529529
if (! isset($raw['__meta'])) {
530530
continue;
531531
}

src/Prometheus/Storage/RedisClients/PHPRedis.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public function del(array|string $key, string ...$other_keys): void
9696
}
9797
}
9898

99+
public function prefix(string $key): string
100+
{
101+
return $this->redis->_prefix($key);
102+
}
103+
99104
/**
100105
* @throws StorageException
101106
*/

src/Prometheus/Storage/RedisClients/Predis.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ public function del(array|string $key, string ...$other_keys): void
120120
$this->client->del($key, ...$other_keys);
121121
}
122122

123+
public function prefix(string $key): string
124+
{
125+
return $this->getOption(RedisClient::OPT_PREFIX).$key;
126+
}
127+
123128
public function ensureOpenConnection(): void
124129
{
125130
// Predis doesn't require to trigger connection

src/Prometheus/Storage/RedisClients/RedisClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,7 @@ public function get(string $key): mixed;
4545
*/
4646
public function del(array|string $key, string ...$other_keys): void;
4747

48+
public function prefix(string $key): string;
49+
4850
public function ensureOpenConnection(): void;
4951
}

0 commit comments

Comments
 (0)