Skip to content

Commit

Permalink
Use promphp instead of endclothing for prometheus_client_php. (…
Browse files Browse the repository at this point in the history
…#3676)
  • Loading branch information
limingxinleo authored Jun 5, 2021
1 parent 5f3cabb commit a89957a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"description": "hyperf metric component",
"require": {
"php": ">=7.3",
"endclothing/prometheus_client_php": "^1.0",
"hyperf/contract": "~2.2.0",
"hyperf/guzzle": "~2.2.0",
"hyperf/utils": "~2.2.0",
"promphp/prometheus_client_php": "^2.2",
"psr/container": "^1.0|^2.0",
"psr/event-dispatcher": "^1.0",
"psr/http-message": "^1.0"
Expand All @@ -39,7 +39,10 @@
"HyperfTest\\Metric\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"optimize-autoloader": true,
"sort-packages": true
},
"extra": {
Expand Down
11 changes: 5 additions & 6 deletions src/Adapter/Prometheus/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
use Prometheus\MetricFamilySamples;
use Prometheus\Storage\Adapter;

/**
* This class is backported from
* endclothing/prometheus_client_php 1.0.* branch.
* The 1.0.* branch requires php7.3, so we cannot
* directly use it in Hyperf as of now.
*/
class Redis implements Adapter
{
public const PROMETHEUS_METRIC_KEYS_SUFFIX = '_METRIC_KEYS';
Expand Down Expand Up @@ -97,6 +91,11 @@ public static function setPrefix(string $prefix): void
* @throws StorageException
*/
public function flushRedis(): void
{
$this->wipeStorage();
}

public function wipeStorage(): void
{
$this->openConnection();
$this->redis->flushAll();
Expand Down

0 comments on commit a89957a

Please sign in to comment.