-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added monitor manager Added getMetrics function to retrieve Prometheus metrics from the database Performance: Sped up JSON decoding for responses smaller than 1MB (configurable)
- Loading branch information
1 parent
7376175
commit 5ddafca
Showing
31 changed files
with
2,087 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
.env | ||
.env.backup | ||
.idea | ||
.php_cs | ||
.php_cs.cache | ||
.phpunit.result.cache | ||
.vscode | ||
.env | ||
.env.backup | ||
clover.xml | ||
composer.lock | ||
ray.php | ||
/build | ||
/coverage | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Monitor manager | ||
|
||
Manages monitoring functions for the server/cluster. | ||
|
||
## Functions | ||
The monitor manager supports the following functions: | ||
|
||
### getMetrics(): Metrics | ||
Get Prometheus metrics of the server | ||
|
||
``` | ||
$arangoClient->monitor()->getMetrics(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ parameters: | |
level: 8 | ||
paths: | ||
- src | ||
universalObjectCratesClasses: | ||
- ArangoClient\Prometheus\Metrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ArangoClient; | ||
|
||
use ArangoClient\Prometheus\Prometheus; | ||
use Psr\Http\Message\ResponseInterface; | ||
use stdClass; | ||
|
||
trait HandlesResponses | ||
{ | ||
use HandlesJson; | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
protected function decodeResponse(ResponseInterface $response): stdClass | ||
{ | ||
$contentType = null; | ||
$rawContentType = $response->getHeader('Content-type'); | ||
if (is_array($rawContentType) && sizeOf($rawContentType) > 0) { | ||
$contentType = $rawContentType[0]; | ||
} | ||
|
||
return match ($contentType) { | ||
"application/json; charset=utf-8" => $this->decodeJsonResponse($response), | ||
"text/plain; charset=utf-8" => $this->decodeTextResponse($response), | ||
default => (object) $response->getBody()->getContents(), | ||
}; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
protected function decodeTextResponse(ResponseInterface $response): stdClass | ||
{ | ||
$prometheus = new Prometheus(); | ||
return $prometheus->parseStream($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ArangoClient\Monitor; | ||
|
||
use ArangoClient\ArangoClient; | ||
use ArangoClient\Manager; | ||
|
||
class MonitorManager extends Manager | ||
{ | ||
public function __construct(protected ArangoClient $arangoClient) {} | ||
|
||
public function getMetrics(): \stdClass | ||
{ | ||
$uri = '/_admin/metrics/v2'; | ||
|
||
return $this->arangoClient->request('get', $uri); | ||
} | ||
} |
Oops, something went wrong.