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

Commit

Permalink
Add Predis support
Browse files Browse the repository at this point in the history
  • Loading branch information
fesor committed Feb 26, 2018
1 parent cf3ea93 commit 69cf060
Show file tree
Hide file tree
Showing 14 changed files with 443 additions and 5 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"phpunit/phpunit": "4.1.0"
"phpunit/phpunit": "4.1.0",
"predis/predis": "^1.1"
},
"suggest": {
"ext-redis": "Required if using Redis.",
"ext-apc": "Required if using APCu."
"predis/predis": "Required if using Predis",
"ext-apcu": "Required if using APCu."
},
"autoload": {
"psr-0": {
Expand Down
5 changes: 5 additions & 0 deletions examples/flush_adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

$redisAdapter = new Prometheus\Storage\Redis(array('host' => REDIS_HOST));
$redisAdapter->flushRedis();
} elseif ($adapter === 'predis') {
$adapter = new Prometheus\Storage\Predis([
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
]);
$adapter->flushRedis();
} elseif ($adapter === 'apc') {
$apcAdapter = new Prometheus\Storage\APC();
$apcAdapter->flushAPC();
Expand Down
4 changes: 4 additions & 0 deletions examples/metrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
if ($adapter === 'redis') {
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
$adapter = new Prometheus\Storage\Redis();
} elseif ($adapter === 'predis') {
$adapter = new Prometheus\Storage\Predis([
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
]);
} elseif ($adapter === 'apc') {
$adapter = new Prometheus\Storage\APC();
} elseif ($adapter === 'in-memory') {
Expand Down
4 changes: 4 additions & 0 deletions examples/pushgateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
if ($adapter === 'redis') {
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
$adapter = new Prometheus\Storage\Redis();
} elseif ($adapter === 'predis') {
$adapter = new Prometheus\Storage\Predis([
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
]);
} elseif ($adapter === 'apc') {
$adapter = new Prometheus\Storage\APC();
} elseif ($adapter === 'in-memory') {
Expand Down
4 changes: 4 additions & 0 deletions examples/some_counter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
if ($adapter === 'redis') {
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
$adapter = new Prometheus\Storage\Redis();
} elseif ($adapter === 'predis') {
$adapter = new Prometheus\Storage\Predis([
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
]);
} elseif ($adapter === 'apc') {
$adapter = new Prometheus\Storage\APC();
} elseif ($adapter === 'in-memory') {
Expand Down
4 changes: 4 additions & 0 deletions examples/some_gauge.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
if ($adapter === 'redis') {
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
$adapter = new Prometheus\Storage\Redis();
} elseif ($adapter === 'predis') {
$adapter = new Prometheus\Storage\Predis([
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
]);
} elseif ($adapter === 'apc') {
$adapter = new Prometheus\Storage\APC();
} elseif ($adapter === 'in-memory') {
Expand Down
4 changes: 4 additions & 0 deletions examples/some_histogram.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
if ($adapter === 'redis') {
Redis::setDefaultOptions(array('host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'));
$adapter = new Prometheus\Storage\Redis();
} elseif ($adapter === 'predis') {
$adapter = new Prometheus\Storage\Predis([
'host' => isset($_SERVER['REDIS_HOST']) ? $_SERVER['REDIS_HOST'] : '127.0.0.1'
]);
} elseif ($adapter === 'apc') {
$adapter = new Prometheus\Storage\APC();
} elseif ($adapter === 'in-memory') {
Expand Down
4 changes: 2 additions & 2 deletions src/Prometheus/PushGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public function pushAdd(CollectorRegistry $collectorRegistry, $job, $groupingKey
* @param $job
* @param $groupingKey
*/
public function delete($job, $groupingKey = null)
public function delete(CollectorRegistry $collectorRegistry, $job, $groupingKey = null)
{
$this->doRequest(null, $job, $groupingKey, 'delete');
$this->doRequest($collectorRegistry, $job, $groupingKey, 'delete');
}

/**
Expand Down
Loading

0 comments on commit 69cf060

Please sign in to comment.