review fixes
This commit is contained in:
parent
d0534becec
commit
de17711c94
@ -149,7 +149,7 @@ file(GLOB CustomizerGlob src/customize/*.cpp)
|
||||
file(GLOB ContractorGlob src/contractor/*.cpp)
|
||||
file(GLOB UpdaterGlob src/updater/*.cpp)
|
||||
file(GLOB StorageGlob src/storage/*.cpp)
|
||||
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp)
|
||||
file(GLOB ServerGlob src/server/*.cpp src/server/**/*.cpp src/monitoring/*.cpp)
|
||||
file(GLOB EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
||||
file(GLOB ErrorcodesGlob src/osrm/errorcodes.cpp)
|
||||
|
||||
@ -726,7 +726,7 @@ file(GLOB FlatbuffersGlob third_party/flatbuffers/include/flatbuffers/*.h)
|
||||
file(GLOB LibraryGlob include/osrm/*.hpp)
|
||||
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
||||
set(ApiHeader include/engine/api/base_result.hpp)
|
||||
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp)
|
||||
set(EngineHeader include/engine/status.hpp include/engine/engine_config.hpp include/engine/hint.hpp include/engine/bearing.hpp include/engine/approach.hpp include/engine/phantom_node.hpp include/engine/engine_info.hpp)
|
||||
set(UtilHeader include/util/coordinate.hpp include/util/json_container.hpp include/util/typedefs.hpp include/util/alias.hpp include/util/exception.hpp include/util/bearing.hpp)
|
||||
set(ExtractorHeader include/extractor/extractor.hpp include/storage/io_config.hpp include/extractor/extractor_config.hpp include/extractor/travel_mode.hpp)
|
||||
set(PartitionerHeader include/partitioner/partitioner.hpp include/partitioner/partitioner_config.hpp)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
## Abstract
|
||||
|
||||
OSRM routed daemon publish helath information in prometheus format.
|
||||
OSRM routed daemon publish health information in prometheus format.
|
||||
This option switched off by default. To enable this feature please set `-P <monitoring_port>` option on OSRM routed startup.
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I monitor I should get$/, (table, callback) => {
|
||||
var got = {};
|
||||
@ -16,9 +14,8 @@ module.exports = function () {
|
||||
var metrics = {};
|
||||
rows.forEach((r) => {
|
||||
if (r.includes('{')) {
|
||||
var k = r.split('{')[0],
|
||||
v = r.split('}')[1].split(' ')[1];
|
||||
metrics[k] = v;
|
||||
var k = r.split('{')[0];
|
||||
metrics[k] = r.split('}')[1].split(' ')[1];
|
||||
} else {
|
||||
var kv = r.split(' ');
|
||||
metrics[kv[0]] = kv[1];
|
||||
@ -34,13 +31,13 @@ module.exports = function () {
|
||||
}
|
||||
|
||||
|
||||
if (!metrics.hasOwnProperty("osrm_routed_instance_info")) {
|
||||
throw new Error("Have no instance information inside the monitoring!");
|
||||
if (!metrics.hasOwnProperty('osrm_routed_instance_info')) {
|
||||
throw new Error('Have no instance information inside the monitoring!');
|
||||
}
|
||||
cb(null, got);
|
||||
};
|
||||
this.requestMonitoring(afterRequest);
|
||||
}
|
||||
};
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
|
||||
@ -27,7 +27,7 @@ module.exports = function () {
|
||||
if (err) {
|
||||
if (err.statusCode === 408) throw new Error('*** osrm monitoring endpoint did not respond');
|
||||
else if (err.code === 'ECONNREFUSED')
|
||||
throw new Error('*** osrm monitoring endpoint is not running', uri);
|
||||
throw new Error('*** osrm monitoring endpoint is not running');
|
||||
} else
|
||||
return callback(err, res, body);
|
||||
}));
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace server
|
||||
|
||||
@ -3,9 +3,6 @@
|
||||
|
||||
#include "server/request_handler.hpp"
|
||||
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
@ -18,32 +15,7 @@ class MonitoringRequestHandler : public RequestHandler
|
||||
public:
|
||||
MonitoringRequestHandler(const unsigned _working_threads) : working_threads(_working_threads) {}
|
||||
|
||||
void HandleRequest(const http::request &, http::reply ¤t_reply)
|
||||
{
|
||||
std::stringstream out_stream;
|
||||
out_stream << "osrm_routed_instance_info{";
|
||||
auto engine_info = service_handler->GetEngineInfo();
|
||||
for (auto record : engine_info)
|
||||
{
|
||||
out_stream << record.first << "=\"" << record.second << '"';
|
||||
out_stream << ',';
|
||||
}
|
||||
out_stream << "working_threads=\"" << working_threads << '"';
|
||||
out_stream << "} 1\n";
|
||||
|
||||
auto counters = service_handler->GetUsage();
|
||||
for (auto counter : counters)
|
||||
{
|
||||
out_stream << "http_requests_count{plugin=\"" << counter.first << "\"} "
|
||||
<< counter.second << "\n";
|
||||
}
|
||||
|
||||
out_stream << "workers_busy " << service_handler->GetLoad() << "\n";
|
||||
|
||||
auto result = out_stream.str();
|
||||
current_reply.content.resize(result.size());
|
||||
std::copy(result.cbegin(), result.cend(), current_reply.content.begin());
|
||||
}
|
||||
void HandleRequest(const http::request &, http::reply ¤t_reply) override;
|
||||
|
||||
private:
|
||||
unsigned working_threads;
|
||||
|
||||
@ -29,9 +29,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#define OSRM_HPP
|
||||
|
||||
#include "engine/api/base_result.hpp"
|
||||
#include "osrm/engine_info.hpp"
|
||||
#include "osrm/osrm_fwd.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/engine_info.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -140,6 +140,6 @@ class OSRM final
|
||||
private:
|
||||
std::unique_ptr<engine::EngineInterface> engine_;
|
||||
};
|
||||
}
|
||||
} // namespace osrm
|
||||
|
||||
#endif // OSRM_HPP
|
||||
|
||||
@ -26,7 +26,7 @@ class RequestHandler
|
||||
|
||||
void RegisterServiceHandler(std::shared_ptr<ServiceHandlerInterface> service_handler);
|
||||
|
||||
//TODO make interface and two siblings
|
||||
// TODO make interface and two siblings for the regular request handler and for the monitoring
|
||||
virtual void HandleRequest(const http::request ¤t_request, http::reply ¤t_reply);
|
||||
|
||||
protected:
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
#include "server/service/base_service.hpp"
|
||||
|
||||
#include "engine/api/base_api.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "engine/engine_info.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
|
||||
43
src/monitoring/monitoring_request_handler.cpp
Normal file
43
src/monitoring/monitoring_request_handler.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include "monitoring/monitoring_request_handler.hpp"
|
||||
|
||||
#include "server/http/reply.hpp"
|
||||
#include "server/http/request.hpp"
|
||||
|
||||
#include "util/log.hpp"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace server
|
||||
{
|
||||
|
||||
void MonitoringRequestHandler::HandleRequest(const http::request &, http::reply ¤t_reply)
|
||||
{
|
||||
std::stringstream out_stream;
|
||||
out_stream << "osrm_routed_instance_info{";
|
||||
auto engine_info = service_handler->GetEngineInfo();
|
||||
for (auto record : engine_info)
|
||||
{
|
||||
out_stream << record.first << "=\"" << record.second << '"';
|
||||
out_stream << ',';
|
||||
}
|
||||
out_stream << "working_threads=\"" << working_threads << '"';
|
||||
out_stream << "} 1\n";
|
||||
|
||||
auto counters = service_handler->GetUsage();
|
||||
for (auto counter : counters)
|
||||
{
|
||||
out_stream << "http_requests_count{plugin=\"" << counter.first << "\"} " << counter.second
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
out_stream << "workers_busy " << service_handler->GetLoad() << "\n";
|
||||
|
||||
auto result = out_stream.str();
|
||||
current_reply.content.resize(result.size());
|
||||
std::copy(result.cbegin(), result.cend(), current_reply.content.begin());
|
||||
}
|
||||
|
||||
} // namespace server
|
||||
} // namespace osrm
|
||||
@ -92,9 +92,6 @@ engine::Status OSRM::Tile(const engine::api::TileParameters ¶ms,
|
||||
return engine_->Tile(params, result);
|
||||
}
|
||||
|
||||
const engine::EngineInfo & OSRM::Info() const
|
||||
{
|
||||
return engine_->GetInfo();
|
||||
}
|
||||
const engine::EngineInfo &OSRM::Info() const { return engine_->GetInfo(); }
|
||||
|
||||
} // ns osrm
|
||||
|
||||
@ -115,8 +115,7 @@ inline unsigned generateServerProgramOptions(const int argc,
|
||||
("port,p",
|
||||
value<int>(&ip_port)->default_value(5000),
|
||||
"TCP/IP port") //
|
||||
(
|
||||
"metrics_port,P",
|
||||
("metrics_port,P",
|
||||
value<int>(&ip_port_metrics)->default_value(0),
|
||||
"TCP/IP port for prometheus metrics exporter. Leave 0 if do not start server for "
|
||||
"metrics") //
|
||||
@ -338,10 +337,8 @@ int main(int argc, const char *argv[]) try
|
||||
#else
|
||||
// Set console control handler to allow server to be stopped.
|
||||
console_ctrl_function = std::bind(&server::Server::Stop, routing_server);
|
||||
console_ctrl_function_monitoring =
|
||||
std::bind(&monitoring::Monitoring::Stop, monitoring_server);
|
||||
console_ctrl_function_monitoring = std::bind(&server::Monitoring::Stop, monitoring_server);
|
||||
SetConsoleCtrlHandler(console_ctrl_handler, TRUE);
|
||||
SetConsoleCtrlHandler(console_ctrl_handler_monitoring, TRUE);
|
||||
util::Log() << "running and waiting for requests";
|
||||
monitoring_server->Run();
|
||||
routing_server->Run();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user