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 ContractorGlob src/contractor/*.cpp)
|
||||||
file(GLOB UpdaterGlob src/updater/*.cpp)
|
file(GLOB UpdaterGlob src/updater/*.cpp)
|
||||||
file(GLOB StorageGlob src/storage/*.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 EngineGlob src/engine/*.cpp src/engine/**/*.cpp)
|
||||||
file(GLOB ErrorcodesGlob src/osrm/errorcodes.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 LibraryGlob include/osrm/*.hpp)
|
||||||
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
file(GLOB ParametersGlob include/engine/api/*_parameters.hpp)
|
||||||
set(ApiHeader include/engine/api/base_result.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(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(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)
|
set(PartitionerHeader include/partitioner/partitioner.hpp include/partitioner/partitioner_config.hpp)
|
||||||
@ -862,4 +862,4 @@ if (ENABLE_NODE_BINDINGS)
|
|||||||
endforeach()
|
endforeach()
|
||||||
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
|
add_library(check-headers STATIC EXCLUDE_FROM_ALL ${sources})
|
||||||
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
|
set_target_properties(check-headers PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${check_headers_dir})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
## Abstract
|
## 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.
|
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';
|
'use strict';
|
||||||
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
this.When(/^I monitor I should get$/, (table, callback) => {
|
this.When(/^I monitor I should get$/, (table, callback) => {
|
||||||
var got = {};
|
var got = {};
|
||||||
@ -16,9 +14,8 @@ module.exports = function () {
|
|||||||
var metrics = {};
|
var metrics = {};
|
||||||
rows.forEach((r) => {
|
rows.forEach((r) => {
|
||||||
if (r.includes('{')) {
|
if (r.includes('{')) {
|
||||||
var k = r.split('{')[0],
|
var k = r.split('{')[0];
|
||||||
v = r.split('}')[1].split(' ')[1];
|
metrics[k] = r.split('}')[1].split(' ')[1];
|
||||||
metrics[k] = v;
|
|
||||||
} else {
|
} else {
|
||||||
var kv = r.split(' ');
|
var kv = r.split(' ');
|
||||||
metrics[kv[0]] = kv[1];
|
metrics[kv[0]] = kv[1];
|
||||||
@ -34,13 +31,13 @@ module.exports = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!metrics.hasOwnProperty("osrm_routed_instance_info")) {
|
if (!metrics.hasOwnProperty('osrm_routed_instance_info')) {
|
||||||
throw new Error("Have no instance information inside the monitoring!");
|
throw new Error('Have no instance information inside the monitoring!');
|
||||||
}
|
}
|
||||||
cb(null, got);
|
cb(null, got);
|
||||||
};
|
};
|
||||||
this.requestMonitoring(afterRequest);
|
this.requestMonitoring(afterRequest);
|
||||||
}
|
};
|
||||||
this.processRowsAndDiff(table, testRow, callback);
|
this.processRowsAndDiff(table, testRow, callback);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -27,7 +27,7 @@ module.exports = function () {
|
|||||||
if (err) {
|
if (err) {
|
||||||
if (err.statusCode === 408) throw new Error('*** osrm monitoring endpoint did not respond');
|
if (err.statusCode === 408) throw new Error('*** osrm monitoring endpoint did not respond');
|
||||||
else if (err.code === 'ECONNREFUSED')
|
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
|
} else
|
||||||
return callback(err, res, body);
|
return callback(err, res, body);
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace server
|
namespace server
|
||||||
|
|||||||
@ -3,9 +3,6 @@
|
|||||||
|
|
||||||
#include "server/request_handler.hpp"
|
#include "server/request_handler.hpp"
|
||||||
|
|
||||||
#include "util/log.hpp"
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
@ -18,32 +15,7 @@ class MonitoringRequestHandler : public RequestHandler
|
|||||||
public:
|
public:
|
||||||
MonitoringRequestHandler(const unsigned _working_threads) : working_threads(_working_threads) {}
|
MonitoringRequestHandler(const unsigned _working_threads) : working_threads(_working_threads) {}
|
||||||
|
|
||||||
void HandleRequest(const http::request &, http::reply ¤t_reply)
|
void HandleRequest(const http::request &, http::reply ¤t_reply) override;
|
||||||
{
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned working_threads;
|
unsigned working_threads;
|
||||||
|
|||||||
@ -29,9 +29,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define OSRM_HPP
|
#define OSRM_HPP
|
||||||
|
|
||||||
#include "engine/api/base_result.hpp"
|
#include "engine/api/base_result.hpp"
|
||||||
|
#include "osrm/engine_info.hpp"
|
||||||
#include "osrm/osrm_fwd.hpp"
|
#include "osrm/osrm_fwd.hpp"
|
||||||
#include "osrm/status.hpp"
|
#include "osrm/status.hpp"
|
||||||
#include "osrm/engine_info.hpp"
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -135,11 +135,11 @@ class OSRM final
|
|||||||
/**
|
/**
|
||||||
* Tile: engine state information for monitoring purposes
|
* Tile: engine state information for monitoring purposes
|
||||||
*/
|
*/
|
||||||
const EngineInfo & Info() const;
|
const EngineInfo &Info() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<engine::EngineInterface> engine_;
|
std::unique_ptr<engine::EngineInterface> engine_;
|
||||||
};
|
};
|
||||||
}
|
} // namespace osrm
|
||||||
|
|
||||||
#endif // OSRM_HPP
|
#endif // OSRM_HPP
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class RequestHandler
|
|||||||
|
|
||||||
void RegisterServiceHandler(std::shared_ptr<ServiceHandlerInterface> service_handler);
|
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);
|
virtual void HandleRequest(const http::request ¤t_request, http::reply ¤t_reply);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -28,7 +28,7 @@ class BaseService
|
|||||||
RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) = 0;
|
RunQuery(std::size_t prefix_length, std::string &query, osrm::engine::api::ResultT &result) = 0;
|
||||||
|
|
||||||
virtual unsigned GetVersion() = 0;
|
virtual unsigned GetVersion() = 0;
|
||||||
uint32_t GetUsage() {return usage;}
|
uint32_t GetUsage() { return usage; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OSRM &routing_machine;
|
OSRM &routing_machine;
|
||||||
|
|||||||
@ -4,8 +4,8 @@
|
|||||||
#include "server/service/base_service.hpp"
|
#include "server/service/base_service.hpp"
|
||||||
|
|
||||||
#include "engine/api/base_api.hpp"
|
#include "engine/api/base_api.hpp"
|
||||||
#include "osrm/osrm.hpp"
|
|
||||||
#include "engine/engine_info.hpp"
|
#include "engine/engine_info.hpp"
|
||||||
|
#include "osrm/osrm.hpp"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -47,7 +47,7 @@ class ServiceHandler final : public ServiceHandlerInterface
|
|||||||
|
|
||||||
virtual engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result) override;
|
virtual engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result) override;
|
||||||
|
|
||||||
virtual const engine::EngineInfo & GetEngineInfo() const override;
|
virtual const engine::EngineInfo &GetEngineInfo() const override;
|
||||||
virtual const HandlersCounter GetUsage() const override;
|
virtual const HandlersCounter GetUsage() const override;
|
||||||
virtual std::uint32_t GetLoad() const override;
|
virtual std::uint32_t GetLoad() const override;
|
||||||
|
|
||||||
|
|||||||
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);
|
return engine_->Tile(params, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
const engine::EngineInfo & OSRM::Info() const
|
const engine::EngineInfo &OSRM::Info() const { return engine_->GetInfo(); }
|
||||||
{
|
|
||||||
return engine_->GetInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // ns osrm
|
} // ns osrm
|
||||||
|
|||||||
@ -115,8 +115,7 @@ inline unsigned generateServerProgramOptions(const int argc,
|
|||||||
("port,p",
|
("port,p",
|
||||||
value<int>(&ip_port)->default_value(5000),
|
value<int>(&ip_port)->default_value(5000),
|
||||||
"TCP/IP port") //
|
"TCP/IP port") //
|
||||||
(
|
("metrics_port,P",
|
||||||
"metrics_port,P",
|
|
||||||
value<int>(&ip_port_metrics)->default_value(0),
|
value<int>(&ip_port_metrics)->default_value(0),
|
||||||
"TCP/IP port for prometheus metrics exporter. Leave 0 if do not start server for "
|
"TCP/IP port for prometheus metrics exporter. Leave 0 if do not start server for "
|
||||||
"metrics") //
|
"metrics") //
|
||||||
@ -338,10 +337,8 @@ int main(int argc, const char *argv[]) try
|
|||||||
#else
|
#else
|
||||||
// Set console control handler to allow server to be stopped.
|
// Set console control handler to allow server to be stopped.
|
||||||
console_ctrl_function = std::bind(&server::Server::Stop, routing_server);
|
console_ctrl_function = std::bind(&server::Server::Stop, routing_server);
|
||||||
console_ctrl_function_monitoring =
|
console_ctrl_function_monitoring = std::bind(&server::Monitoring::Stop, monitoring_server);
|
||||||
std::bind(&monitoring::Monitoring::Stop, monitoring_server);
|
|
||||||
SetConsoleCtrlHandler(console_ctrl_handler, TRUE);
|
SetConsoleCtrlHandler(console_ctrl_handler, TRUE);
|
||||||
SetConsoleCtrlHandler(console_ctrl_handler_monitoring, TRUE);
|
|
||||||
util::Log() << "running and waiting for requests";
|
util::Log() << "running and waiting for requests";
|
||||||
monitoring_server->Run();
|
monitoring_server->Run();
|
||||||
routing_server->Run();
|
routing_server->Run();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user