8000 enable process metrics on agents (#14453) · arangodb/arangodb@abf7156 · GitHub
[go: up one dir, main page]

Skip to content

Commit abf7156

Browse files
jsteemannmaierlars
authored and
maierlars
committed
enable process metrics on agents (#14453)
1 parent 254986b commit abf7156

File tree

5 files changed

+124
-13
lines changed

5 files changed

+124
-13
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
devel
22
-----
33

4+
* Enable process metrics on agent instances by default. Previously, some
5+
metrics (including the metrics starting with `arangodb_process` prefix) were
6+
not returned by agent instances.
7+
48
* Fix potential memleak in Pregel conductor garbage collection.
59

610
* Added a retry loop for arangorestore during the initial connection phase. The

arangod/Statistics/StatisticsFeature.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ void StatisticsFeature::start() {
614614
FATAL_ERROR_EXIT();
615615
}
616616

617-
_statisticsThread.reset(new StatisticsThread(server()));
617+
_statisticsThread = std::make_unique<StatisticsThread>(server());
618618

619619
if (!_statisticsThread->start()) {
620620
LOG_TOPIC("46b0c", FATAL, arangodb::Logger::STATISTICS)
@@ -633,17 +633,15 @@ void StatisticsFeature::start() {
633633
_statisticsHistory = false;
634634
}
635635

636-
if (_statisticsHistory) {
637-
TRI_ASSERT(!ServerState::instance()->isDBServer());
638-
639-
_statisticsWorker.reset(new StatisticsWorker(*vocbase));
636+
_statisticsWorker = std::make_unique<StatisticsWorker>(*vocbase);
640637

638+
if (_statisticsHistory) {
641639
if (!_statisticsWorker->start()) {
642640
LOG_TOPIC("6ecdc", FATAL, arangodb::Logger::STATISTICS)
643641
<< "could not start statistics worker";
644642
FATAL_ERROR_EXIT();
645643
}
646-
} // if
644+
}
647645
}
648646

649647
void StatisticsFeature::stop() {
@@ -655,7 +653,7 @@ void StatisticsFeature::stop() {
655653
}
656654
}
657655

658-
if (_statisticsWorker != nullptr) {
656+
if (_statisticsHistory && _statisticsWorker != nullptr) {
659657
_statisticsWorker->beginShutdown();
660658

661659
while (_statisticsWorker->isRunning()) {

arangod/Statistics/StatisticsWorker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ using namespace arangodb::statistics;
9696
StatisticsWorker::StatisticsWorker(TRI_vocbase_t& vocbase)
9797
: Thread(vocbase.server(), "StatisticsWorker"), _gcTask(GC_STATS), _vocbase(vocbase) {
9898

99-
// statistics queries don't work on DB servers, so we should not
100-
// run the StatisticsWorker on DB servers!
101-
TRI_ASSERT(!ServerState::instance()->isDBServer());
102-
10399
_bytesSentDistribution.openArray();
104100

105101
for (auto const& val : BytesSentDistributionCuts) {

scripts/startLocalCluster.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ start() {
239239
--log.role true \
240240
--log.file cluster/$PORT.log \
241241
--log.level $LOG_LEVEL \
242-
--server.statistics true \
243242
--javascript.startup-directory $SRC_DIR/js \
244243
--javascript.module-directory $SRC_DIR/enterprise/js \
245244
--javascript.app-path cluster/apps$PORT \
@@ -265,7 +264,6 @@ start() {
265264
--log.role true \
266265
--log.file cluster/$PORT.log \
267266
--log.level $LOG_LEVEL \
268-
--server.statistics true \
269267
--javascript.startup-directory $SRC_DIR/js \
270268
--javascript.module-directory $SRC_DIR/enterprise/js \
271269
--javascript.app-path cluster/apps$PORT \
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/* jshint globalstrict:false, strict:false, maxlen: 200 */
2+
/* global assertEqual, assertTrue */
3+
4+
// //////////////////////////////////////////////////////////////////////////////
5+
// / DISCLAIMER
6+
// /
7+
// / Copyright 2018 ArangoDB GmbH, Cologne, Germany
8+
// /
9+
// / Licensed under the Apache License, Version 2.0 (the "License")
< A3D4 /code>
10+
// / you may not use this file except in compliance with the License.
11+
// / You may obtain a copy of the License at
12+
// /
13+
// / http://www.apache.org/licenses/LICENSE-2.0
14+
// /
15+
// / Unless required by applicable law or agreed to in writing, software
16+
// / distributed under the License is distributed on an "AS IS" BASIS,
17+
// / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
// / See the License for the specific language governing permissions and
19+
// / limitations under the License.
20+
// /
21+
// / Copyright holder is triAGENS GmbH, Cologne, Germany
22+
// /
23+
// / @author Jan Steemann
24+
// //////////////////////////////////////////////////////////////////////////////
25+
26+
let jsunity = require('jsunity');
27+
let internal = require('internal');
28+
const request = require('@arangodb/request');
29+
30+
function getEndpointsByType(type) {
31+
const isType = (d) => (d.role.toLowerCase() === type);
32+
const toEndpoint = (d) => (d.endpoint);
33+
const endpointToURL = (endpoint) => {
34+
if (endpoint.substr(0, 6) === 'ssl://') {
35+
return 'https://' + endpoint.substr(6);
36+
}
37+
let pos = endpoint.indexOf('://');
38+
if (pos === -1) {
39+
return 'http://' + endpoint;
40+
}
41+
return 'http' + endpoint.substr(pos);
42+
};
43+
44+
const instanceInfo = JSON.parse(internal.env.INSTANCEINFO);
45+
return instanceInfo.arangods.filter(isType)
46+
.map(toEndpoint)
47+
.map(endpointToURL);
48+
}
49+
50+
function getMetric(endpoint, name) {
51+
let res = request.get({
52+
url: endpoint + '/_admin/metrics',
53+
});
54+
let re = new RegExp("^" + name);
55+
let matches = res.body.split('\n').filter((line) => !line.match(/^#/)).filter((line) => line.match(re));
56+
if (!matches.length) {
57+
throw "Metric " + name + " not found";
58+
}
59+
return Number(matches[0].replace(/^.*? (\d+(\.\d+)?)$/, '$1'));
60+
}
61+
62+
function processMetricsSuite() {
63+
'use strict';
64+
65+
const metrics = [
66+
"arangodb_process_statistics_user_time",
67+
"arangodb_process_statistics_system_time",
68+
"arangodb_process_statistics_number_of_threads",
69+
"arangodb_process_statistics_resident_set_size",
70+
"arangodb_process_statistics_virtual_memory_size",
71+
];
72+
73+
return {
74+
75+
testMetricsOnAgent: function () {
76+
let endpoints = getEndpointsByType('agent');
77+
assertTrue(endpoints.length > 0);
78+
79+
endpoints.forEach((ep) => {
80+
metrics.forEach((m) => {
81+
let value = getMetric(ep, m);
82+
assertEqual("number", typeof value);
83+
});
84+
});
85+
},
86+
87+
testMetricsOnCoordinator: function () {
88+
let endpoints = getEndpointsByType('coordinator');
89+
assertTrue(endpoints.length > 0);
90+
91+
endpoints.forEach((ep) => {
92+
metrics.forEach((m) => {
93+
let value = getMetric(ep, m);
94+
assertEqual("number", typeof value);
95+
});
96+
});
97+
},
98+
99+
testMetricsOnDBServer: function () {
100+
let endpoints = getEndpointsByType('dbserver');
101+
assertTrue(endpoints.length > 0);
102+
103+
endpoints.forEach((ep) => {
104+
metrics.forEach((m) => {
105+
let value = getMetric(ep, m);
106+
assertEqual("number", typeof value);
107+
});
108+
});
109+
},
110+
111+
};
112+
}
113+
114+
jsunity.run(processMetricsSuite);
115+
return jsunity.done();

0 commit comments

Comments
 (0)
0