Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit 8d21a57

Browse files
committed
Add Predis support
1 parent 07cc7ec commit 8d21a57

14 files changed

Lines changed: 443 additions & 5 deletions

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
"guzzlehttp/guzzle": "^6.2"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "4.1.0"
18+
"phpunit/phpunit": "4.1.0",
19+
"predis/predis": "^1.1"
1920
},
2021
"suggest": {
2122
"ext-redis": "Required if using Redis.",
22-
"ext-apc": "Required if using APCu."
23+
"predis/predis": "Required if using Predis",
24+
"ext-apcu": "Required if using APCu."
2325
},
2426
"autoload": {
2527
"psr-0": {

examples/flush_adapter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
$redisAdapter = new Prometheus\Storage\Redis(array('host' => REDIS_HOST));
1010
$redisAdapter->flushRedis();
11+
} elseif ($adapter === 'predis') {
12+
$adapter = new Prometheus\Storage\Predis([
13+
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
14+
]);
15+
$adapter->flushRedis();
1116
} elseif ($adapter === 'apc') {
1217
$apcAdapter = new Prometheus\Storage\APC();
1318
$apcAdapter->flushAPC();

examples/metrics.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
if ($adapter === 'redis') {
1212
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
1313
$adapter = new Prometheus\Storage\Redis();
14+
} elseif ($adapter === 'predis') {
15+
$adapter = new Prometheus\Storage\Predis([
16+
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
17+
]);
1418
} elseif ($adapter === 'apc') {
1519
$adapter = new Prometheus\Storage\APC();
1620
} elseif ($adapter === 'in-memory') {

examples/pushgateway.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
if ($adapter === 'redis') {
1010
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
1111
$adapter = new Prometheus\Storage\Redis();
12+
} elseif ($adapter === 'predis') {
13+
$adapter = new Prometheus\Storage\Predis([
14+
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
15+
]);
1216
} elseif ($adapter === 'apc') {
1317
$adapter = new Prometheus\Storage\APC();
1418
} elseif ($adapter === 'in-memory') {

examples/some_counter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
if ($adapter === 'redis') {
1111
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
1212
$adapter = new Prometheus\Storage\Redis();
13+
} elseif ($adapter === 'predis') {
14+
$adapter = new Prometheus\Storage\Predis([
15+
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
16+
]);
1317
} elseif ($adapter === 'apc') {
1418
$adapter = new Prometheus\Storage\APC();
1519
} elseif ($adapter === 'in-memory') {

examples/some_gauge.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
if ($adapter === 'redis') {
1414
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
1515
$adapter = new Prometheus\Storage\Redis();
16+
} elseif ($adapter === 'predis') {
17+
$adapter = new Prometheus\Storage\Predis([
18+
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
19+
]);
1620
} elseif ($adapter === 'apc') {
1721
$adapter = new Prometheus\Storage\APC();
1822
} elseif ($adapter === 'in-memory') {

examples/some_histogram.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
if ($adapter === 'redis') {
1313
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
1414
$adapter = new Prometheus\Storage\Redis();
15+
} elseif ($adapter === 'predis') {
16+
$adapter = new Prometheus\Storage\Predis([
17+
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
18+
]);
1519
} elseif ($adapter === 'apc') {
1620
$adapter = new Prometheus\Storage\APC();
1721
} elseif ($adapter === 'in-memory') {

src/Prometheus/PushGateway.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function pushAdd(CollectorRegistry $collectorRegistry, $job, $groupingKey
4949
* @param $job
5050
* @param $groupingKey
5151
*/
52-
public function delete($job, $groupingKey = null)
52+
public function delete(CollectorRegistry $collectorRegistry, $job, $groupingKey = null)
5353
{
54-
$this->doRequest(null, $job, $groupingKey, 'delete');
54+
$this->doRequest($collectorRegistry, $job, $groupingKey, 'delete');
5555
}
5656

5757
/**

0 commit comments

Comments
 (0)