From: ghyer Date: Mon, 3 Aug 2020 07:36:27 +0000 (+0800) Subject: mon: add "duration" field for monitors' operation log. X-Git-Tag: v17.0.0~1511^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=52e5fca55046e3868be8b359ffcd3d78440fbc80;p=ceph.git mon: add "duration" field for monitors' operation log. Signed-off-by: Haoyu Gao --- diff --git a/src/mon/MonOpRequest.h b/src/mon/MonOpRequest.h index 13f6d5aed5820..09c7a37537d37 100644 --- a/src/mon/MonOpRequest.h +++ b/src/mon/MonOpRequest.h @@ -105,9 +105,21 @@ private: { f->open_array_section("events"); std::lock_guard l(lock); - for (auto& i : events) { - f->dump_object("event", i); + for (auto i = events.begin(); i != events.end(); ++i) { + f->open_object_section("event"); + f->dump_string("event", i->str); + f->dump_stream("time") << i->stamp; + + auto i_next = i + 1; + + if (i_next < events.end()) { + f->dump_float("duration", i_next->stamp - i->stamp); + } else { + f->dump_float("duration", events.rbegin()->stamp - get_initiated()); } + + f->close_section(); + } f->close_section(); f->open_object_section("info"); f->dump_int("seq", seq);