Introduce metric to measure the length of the SLAM queue (#1117)

master
Christoph Schütte 2018-04-25 22:09:56 +02:00 committed by Wally B. Feed
parent 5356bdf9a8
commit 666095cb41
2 changed files with 12 additions and 0 deletions

View File

@ -44,6 +44,7 @@ namespace cartographer {
namespace cloud { namespace cloud {
namespace { namespace {
static auto* kIncomingDataQueueMetric = metrics::Gauge::Null();
const common::Duration kPopTimeout = common::FromMilliseconds(100); const common::Duration kPopTimeout = common::FromMilliseconds(100);
} // namespace } // namespace
@ -135,6 +136,7 @@ void MapBuilderServer::Shutdown() {
void MapBuilderServer::ProcessSensorDataQueue() { void MapBuilderServer::ProcessSensorDataQueue() {
LOG(INFO) << "Starting SLAM thread."; LOG(INFO) << "Starting SLAM thread.";
while (!shutting_down_) { while (!shutting_down_) {
kIncomingDataQueueMetric->Set(incoming_data_queue_.Size());
std::unique_ptr<MapBuilderContextInterface::Data> sensor_data = std::unique_ptr<MapBuilderContextInterface::Data> sensor_data =
incoming_data_queue_.PopWithTimeout(kPopTimeout); incoming_data_queue_.PopWithTimeout(kPopTimeout);
if (sensor_data) { if (sensor_data) {
@ -233,5 +235,12 @@ void MapBuilderServer::WaitUntilIdle() {
map_builder_->pose_graph()->RunFinalOptimization(); map_builder_->pose_graph()->RunFinalOptimization();
} }
void MapBuilderServer::RegisterMetrics(metrics::FamilyFactory* factory) {
auto* queue_length = factory->NewGaugeFamily(
"cloud_internal_map_builder_server_incoming_data_queue_length",
"Incoming SLAM Data Queue length");
kIncomingDataQueueMetric = queue_length->Add({});
}
} // namespace cloud } // namespace cloud
} // namespace cartographer } // namespace cartographer

View File

@ -31,6 +31,7 @@
#include "cartographer/mapping/local_slam_result_data.h" #include "cartographer/mapping/local_slam_result_data.h"
#include "cartographer/mapping/map_builder.h" #include "cartographer/mapping/map_builder.h"
#include "cartographer/mapping/trajectory_builder_interface.h" #include "cartographer/mapping/trajectory_builder_interface.h"
#include "cartographer/metrics/family_factory.h"
#include "cartographer/sensor/internal/dispatchable.h" #include "cartographer/sensor/internal/dispatchable.h"
namespace cartographer { namespace cartographer {
@ -91,6 +92,8 @@ class MapBuilderServer : public MapBuilderServerInterface {
// thread. // thread.
void Shutdown() final; void Shutdown() final;
static void RegisterMetrics(metrics::FamilyFactory* family_factory);
private: private:
using LocalSlamResultHandlerSubscriptions = using LocalSlamResultHandlerSubscriptions =
std::map<int /* subscription_index */, std::map<int /* subscription_index */,