]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add "duration" field for monitors' operation log. 36424/head
authorghyer <i@ghyer.com>
Mon, 3 Aug 2020 07:36:27 +0000 (15:36 +0800)
committerghyer <i@ghyer.com>
Mon, 3 Aug 2020 07:36:27 +0000 (15:36 +0800)
Signed-off-by: Haoyu Gao <i@ghyer.com>
src/mon/MonOpRequest.h

index 13f6d5aed58206a3c7b45a91b480fe6d72ee73a4..09c7a37537d37b1e8d16fde3dc6b7fb1296753c2 100644 (file)
@@ -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);