@@ -21,7 +21,7 @@ class Redis implements Adapter
21
21
/**
22
22
* @var mixed[]
23
23
*/
24
- private static $ defaultOptions = [
24
+ protected static $ defaultOptions = [
25
25
'host ' => '127.0.0.1 ' ,
26
26
'port ' => 6379 ,
27
27
'timeout ' => 0.1 ,
@@ -33,22 +33,22 @@ class Redis implements Adapter
33
33
/**
34
34
* @var string
35
35
*/
36
- private static $ prefix = 'PROMETHEUS_ ' ;
36
+ protected static $ prefix = 'PROMETHEUS_ ' ;
37
37
38
38
/**
39
39
* @var mixed[]
40
40
*/
41
- private $ options = [];
41
+ protected $ options = [];
42
42
43
43
/**
44
44
* @var \Redis
45
45
*/
46
- private $ redis ;
46
+ protected $ redis ;
47
47
48
48
/**
49
49
* @var boolean
50
50
*/
51
- private $ connectionInitialized = false ;
51
+ protected $ connectionInitialized = false ;
52
52
53
53
/**
54
54
* Redis constructor.
@@ -63,9 +63,9 @@ public function __construct(array $options = [])
63
63
/**
64
64
* @param \Redis $redis
65
65
* @return self
66
- * @throws StorageException
66
+ * @throws StorageException|\RedisException
67
67
*/
68
- public static function fromExistingConnection (\ Redis $ redis ): self
68
+ public static function fromExistingConnection ($ redis ): self
69
69
{
70
70
if ($ redis ->isConnected () === false ) {
71
71
throw new StorageException ('Connection to Redis server not established ' );
@@ -143,7 +143,7 @@ public function wipeStorage(): void
143
143
*
144
144
* @return string
145
145
*/
146
- private function metaKey (array $ data ): string
146
+ protected function metaKey (array $ data ): string
147
147
{
148
148
return implode (': ' , [
149
149
$ data ['name ' ],
@@ -156,7 +156,7 @@ private function metaKey(array $data): string
156
156
*
157
157
* @return string
158
158
*/
159
- private function valueKey (array $ data ): string
159
+ protected function valueKey (array $ data ): string
160
160
{
161
161
return implode (': ' , [
162
162
$ data ['name ' ],
@@ -187,7 +187,7 @@ function (array $metric): MetricFamilySamples {
187
187
/**
188
188
* @throws StorageException
189
189
*/
190
- private function ensureOpenConnection (): void
190
+ protected function ensureOpenConnection (): void
191
191
{
192
192
if ($ this ->connectionInitialized === true ) {
193
193
return ;
@@ -211,7 +211,7 @@ private function ensureOpenConnection(): void
211
211
/**
212
212
* @throws StorageException
213
213
*/
214
- private function connectToServer (): void
214
+ protected function connectToServer (): void
215
215
{
216
216
try {
217
217
$ connection_successful = false ;
@@ -379,7 +379,7 @@ public function updateCounter(array $data): void
379
379
* @param mixed[] $data
380
380
* @return mixed[]
381
381
*/
382
- private function metaData (array $ data ): array
382
+ protected function metaData (array $ data ): array
383
383
{
384
384
$ metricsMetaData = $ data ;
385
385
unset($ metricsMetaData ['value ' ], $ metricsMetaData ['command ' ], $ metricsMetaData ['labelValues ' ]);
@@ -389,7 +389,7 @@ private function metaData(array $data): array
389
389
/**
390
390
* @return mixed[]
391
391
*/
392
- private function collectHistograms (): array
392
+ protected function collectHistograms (): array
393
393
{
394
394
$ keys = $ this ->redis ->sMembers (self ::$ prefix . Histogram::TYPE . self ::PROMETHEUS_METRIC_KEYS_SUFFIX );
395
395
sort ($ keys );
@@ -471,7 +471,7 @@ private function collectHistograms(): array
471
471
*
472
472
* @return string
473
473
*/
474
- private function removePrefixFromKey (string $ key ): string
474
+ protected function removePrefixFromKey (string $ key ): string
475
475
{
476
476
// @phpstan-ignore-next-line false positive, phpstan thinks getOptions returns int
477
477
if ($ this ->redis ->getOption (\Redis::OPT_PREFIX ) === null ) {
@@ -484,7 +484,7 @@ private function removePrefixFromKey(string $key): string
484
484
/**
485
485
* @return mixed[]
486
486
*/
487
- private function collectSummaries (): array
487
+ protected function collectSummaries (): array
488
488
{
489
489
$ math = new Math ();
490
490
$ summaryKey = self ::$ prefix . Summary::TYPE . self ::PROMETHEUS_METRIC_KEYS_SUFFIX ;
@@ -572,7 +572,7 @@ private function collectSummaries(): array
572
572
/**
573
573
* @return mixed[]
574
574
*/
575
- private function collectGauges (bool $ sortMetrics = true ): array
575
+ protected function collectGauges (bool $ sortMetrics = true ): array
576
576
{
577
577
$ keys = $ this ->redis ->sMembers (self ::$ prefix . Gauge::TYPE . self ::PROMETHEUS_METRIC_KEYS_SUFFIX );
578
578
sort ($ keys );
@@ -608,7 +608,7 @@ private function collectGauges(bool $sortMetrics = true): array
608
608
/**
609
609
* @return mixed[]
610
610
*/
611
- private function collectCounters (bool $ sortMetrics = true ): array
611
+ protected function collectCounters (bool $ sortMetrics = true ): array
612
612
{
613
613
$ keys = $ this ->redis ->sMembers (self ::$ prefix . Counter::TYPE . self ::PROMETHEUS_METRIC_KEYS_SUFFIX );
614
614
sort ($ keys );
@@ -645,7 +645,7 @@ private function collectCounters(bool $sortMetrics = true): array
645
645
* @param int $cmd
646
646
* @return string
647
647
*/
648
- private function getRedisCommand (int $ cmd ): string
648
+ protected function getRedisCommand (int $ cmd ): string
649
649
{
650
650
switch ($ cmd ) {
651
651
case Adapter::COMMAND_INCREMENT_INTEGER :
@@ -663,7 +663,7 @@ private function getRedisCommand(int $cmd): string
663
663
* @param mixed[] $data
664
664
* @return string
665
665
*/
666
- private function toMetricKey (array $ data ): string
666
+ protected function toMetricKey (array $ data ): string
667
667
{
668
668
return implode (': ' , [self ::$ prefix , $ data ['type ' ], $ data ['name ' ]]);
669
669
}
@@ -673,7 +673,7 @@ private function toMetricKey(array $data): string
673
673
* @return string
674
674
* @throws RuntimeException
675
675
*/
676
- private function encodeLabelValues (array $ values ): string
676
+ protected function encodeLabelValues (array $ values ): string
677
677
{
678
678
$ json = json_encode ($ values );
679
679
if (false === $ json ) {
@@ -687,7 +687,7 @@ private function encodeLabelValues(array $values): string
687
687
* @return mixed[]
688
688
* @throws RuntimeException
689
689
*/
690
- private function decodeLabelValues (string $ values ): array
690
+ protected function decodeLabelValues (string $ values ): array
691
691
{
692
692
$ json = base64_decode ($ values , true );
693
693
if (false === $ json ) {
0 commit comments