From 1caa2f5bd655ccd2ae5de1f632ea0f73f4c601ed Mon Sep 17 00:00:00 2001 From: Bas Date: Sun, 10 Nov 2024 23:38:24 +0100 Subject: [PATCH] Feature: Added getCurrentConnections to MonitorManager.php --- src/Monitor/MonitorManager.php | 7 +++++++ tests/MonitorManagerTest.php | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/Monitor/MonitorManager.php b/src/Monitor/MonitorManager.php index 0ab0f0d..772cec1 100644 --- a/src/Monitor/MonitorManager.php +++ b/src/Monitor/MonitorManager.php @@ -17,4 +17,11 @@ public function getMetrics(): \stdClass return $this->arangoClient->request('get', $uri); } + + public function getCurrentConnections(): int + { + $metrics = $this->getMetrics(); + + return $metrics->arangodb_http1_connections_total->value + $metrics->arangodb_http2_connections_total->value; + } } diff --git a/tests/MonitorManagerTest.php b/tests/MonitorManagerTest.php index 4f941db..23d9dea 100644 --- a/tests/MonitorManagerTest.php +++ b/tests/MonitorManagerTest.php @@ -74,3 +74,10 @@ $result = $prometheus->parseText($rawMetrics); expect($result->arangodb_aql_local_query_memory_limit_reached_total->timestamp)->toEqual(2211753600); }); + +test('getCurrentConnections', function () { + $result = $this->arangoClient->monitor()->getCurrentConnections(); + + expect($result)->toBeInt(); + expect($result)->toBeGreaterThan(0); +});