8000 fix metrics handling after server-side change · arangodb/arangodb-php@00e25f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00e25f3

Browse files
committed
fix metrics handling after server-side change
1 parent 9405237 commit 00e25f3

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

lib/ArangoDBClient/AdminHandler.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public function getServerMetrics()
292292
if (trim($line) == "") {
293293
continue;
294294
}
295+
295296
if ($line[0] == "#") {
296297
// type or help
297298
if (!preg_match("/^#\s*([^\s]+)\s+([^\s]+)\s+(.*)$/", $line, $matches)) {
@@ -306,10 +307,10 @@ public function getServerMetrics()
306307
$metrics[$metric][strtolower($matches[1])] = $matches[3];
307308
} else {
308309
// metric value
309-
if (!preg_match("/^([^\s]+?)(\{.*?\})?\s+(.+)$\s*$/", $line, $matches)) {
310+
if (!preg_match("/^([^\s\{]+)(\{.*?\})?\s*(.+)$\s*$/", $line, $matches)) {
310311
throw new ClientException('Invalid metrics API output line: "' . $line. '"');
311312
}
312-
313+
313314
$metric = $matches[1];
314315
$sub = null;
315316
if (preg_match("/_(sum|count|bucket)$/", $metric, $sub)) {
@@ -325,23 +326,25 @@ public function getServerMetrics()
325326
// labels
326327
if ($matches[2] != "") {
327328
$labels = substr($matches[2], 1, strlen($matches[2]) - 2);
328-
foreach (explode(",", $labels) as $label) {
329-
$parts = explode("=", $label);
330-
$key = trim($parts[0]);
331-
$value = trim($parts[1], " \"");
332-
if (!isset($metrics[$metric]["labels"])) {
333-
$metrics[$metric]["labels"] = [];
334-
}
335-
if ($key != "le") {
336-
$metrics[$metric]["labels"][$key] = $value;
337-
} else {
338-
$le = $value;
329+
if ($labels != "") {
330+
foreach (explode(",", $labels) as $label) {
331+
$parts = explode("=", $label);
332+
$key = trim($parts[0]);
333+
$value = trim($parts[1], " \"");
334+
if (!isset($metrics[$metric]["labels"])) {
335+
$metrics[$metric]["labels"] = [];
336+
}
337+
if ($key != "le") {
338+
$metrics[$metric]["labels"][$key] = $value;
339+
} else {
340+
$le = $value;
341+
}
339342
}
340343
}
341344
}
342345

343346
// cast to number
344-
$value = $matches[3] + 0;
347+
$value = $matches[3];
345348

346349
if ($sub == null) {
347350
// counter

lib/ArangoDBClient/Urls.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ abstract class Urls
216216
/**
217217
* base URL part for admin statistics
218218
*/
219-
const URL_ADMIN_METRICS = '/_admin/metrics/v2';
219+
const URL_ADMIN_METRICS = '/_admin/metrics';
220220

221221
/**
222222
* base URL part for admin statistics (deprecated)

0 commit comments

Comments
 (0)
0