diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 122d11a..cb1d567 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -28,6 +28,7 @@ class Redis implements Adapter 'read_timeout' => '10', 'persistent_connections' => false, 'password' => null, + 'user' => null, ]; /** @@ -196,8 +197,18 @@ private function ensureOpenConnection(): void $this->connectToServer(); - if ($this->options['password'] !== null) { - $this->redis->auth($this->options['password']); + $authParams = []; + + if (isset($this->options['user'])) { + $authParams[] = $this->options['user']; + } + + if (isset($this->options['password'])) { + $authParams[] = $this->options['password']; + } + + if (!empty($authParams)) { + $this->redis->auth($authParams); } if (isset($this->options['database'])) {