From 1cae11593d813df7be11e45dc3722caadff2899f Mon Sep 17 00:00:00 2001 From: Michael Grupp Date: Wed, 29 Jul 2020 11:53:14 +0200 Subject: [PATCH] Add gauge metric for pose graph work queue size. (#1727) Signed-off-by: Michael Grupp --- cartographer/mapping/internal/2d/pose_graph_2d.cc | 7 +++++++ cartographer/mapping/internal/3d/pose_graph_3d.cc | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/cartographer/mapping/internal/2d/pose_graph_2d.cc b/cartographer/mapping/internal/2d/pose_graph_2d.cc index 6ccf43b..fe85dce 100644 --- a/cartographer/mapping/internal/2d/pose_graph_2d.cc +++ b/cartographer/mapping/internal/2d/pose_graph_2d.cc @@ -42,6 +42,7 @@ namespace cartographer { namespace mapping { static auto* kWorkQueueDelayMetric = metrics::Gauge::Null(); +static auto* kWorkQueueSizeMetric = metrics::Gauge::Null(); static auto* kConstraintsSameTrajectoryMetric = metrics::Gauge::Null(); static auto* kConstraintsDifferentTrajectoryMetric = metrics::Gauge::Null(); static auto* kActiveSubmapsMetric = metrics::Gauge::Null(); @@ -181,6 +182,7 @@ void PoseGraph2D::AddWorkItem( } const auto now = std::chrono::steady_clock::now(); work_queue_->push_back({now, work_item}); + kWorkQueueSizeMetric->Set(work_queue_->size()); kWorkQueueDelayMetric->Set( std::chrono::duration_cast>( now - work_queue_->front().time) @@ -529,6 +531,7 @@ void PoseGraph2D::DrainWorkQueue() { work_item = work_queue_->front().task; work_queue_->pop_front(); work_queue_size = work_queue_->size(); + kWorkQueueSizeMetric->Set(work_queue_size); } process_work_queue = work_item() == WorkItem::Result::kDoNotRunOptimization; } @@ -1288,6 +1291,10 @@ void PoseGraph2D::RegisterMetrics(metrics::FamilyFactory* family_factory) { "mapping_2d_pose_graph_work_queue_delay", "Age of the oldest entry in the work queue in seconds"); kWorkQueueDelayMetric = latency->Add({}); + auto* queue_size = + family_factory->NewGaugeFamily("mapping_2d_pose_graph_work_queue_size", + "Number of items in the work queue"); + kWorkQueueSizeMetric = queue_size->Add({}); auto* constraints = family_factory->NewGaugeFamily( "mapping_2d_pose_graph_constraints", "Current number of constraints in the pose graph"); diff --git a/cartographer/mapping/internal/3d/pose_graph_3d.cc b/cartographer/mapping/internal/3d/pose_graph_3d.cc index cd47073..d6410f7 100644 --- a/cartographer/mapping/internal/3d/pose_graph_3d.cc +++ b/cartographer/mapping/internal/3d/pose_graph_3d.cc @@ -40,6 +40,7 @@ namespace cartographer { namespace mapping { static auto* kWorkQueueDelayMetric = metrics::Gauge::Null(); +static auto* kWorkQueueSizeMetric = metrics::Gauge::Null(); static auto* kConstraintsSameTrajectoryMetric = metrics::Gauge::Null(); static auto* kConstraintsDifferentTrajectoryMetric = metrics::Gauge::Null(); static auto* kActiveSubmapsMetric = metrics::Gauge::Null(); @@ -169,6 +170,7 @@ void PoseGraph3D::AddWorkItem( } const auto now = std::chrono::steady_clock::now(); work_queue_->push_back({now, work_item}); + kWorkQueueSizeMetric->Set(work_queue_->size()); kWorkQueueDelayMetric->Set( std::chrono::duration_cast>( now - work_queue_->front().time) @@ -516,6 +518,7 @@ void PoseGraph3D::DrainWorkQueue() { work_item = work_queue_->front().task; work_queue_->pop_front(); work_queue_size = work_queue_->size(); + kWorkQueueSizeMetric->Set(work_queue_size); } process_work_queue = work_item() == WorkItem::Result::kDoNotRunOptimization; } @@ -1268,6 +1271,10 @@ void PoseGraph3D::RegisterMetrics(metrics::FamilyFactory* family_factory) { "mapping_3d_pose_graph_work_queue_delay", "Age of the oldest entry in the work queue in seconds"); kWorkQueueDelayMetric = latency->Add({}); + auto* queue_size = + family_factory->NewGaugeFamily("mapping_3d_pose_graph_work_queue_size", + "Number of items in the work queue"); + kWorkQueueSizeMetric = queue_size->Add({}); auto* constraints = family_factory->NewGaugeFamily( "mapping_3d_pose_graph_constraints", "Current number of constraints in the pose graph");