]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: add transaction id to ops log.
authorzhang Shaowen <zhangshaowen@cmss.chinamobile.com>
Thu, 5 Sep 2019 06:22:18 +0000 (14:22 +0800)
committerzhang Shaowen <zhangshaowen@cmss.chinamobile.com>
Thu, 5 Sep 2019 06:22:18 +0000 (14:22 +0800)
Fixes: https://tracker.ceph.com/issues/39262
Signed-off-by: zhang Shaowen <zhangshaowen@cmss.chinamobile.com>
src/rgw/rgw_dencoder.cc
src/rgw/rgw_json_enc.cc
src/rgw/rgw_log.cc
src/rgw/rgw_log.h

index 41216fe91b27e643e423f4b1046a017e53433c96..867b504fb4a3d70a4245b545b63c9e61c6939d24 100644 (file)
@@ -232,6 +232,7 @@ void rgw_log_entry::generate_test_instances(list<rgw_log_entry*>& o)
   e->user_agent = "user_agent";
   e->referrer = "referrer";
   e->bucket_id = "10";
+  e->trans_id = "trans_id";
   o.push_back(e);
   o.push_back(new rgw_log_entry);
 }
index 6b4756cda9054d7bfb95e68b3f38b75ee787fc9f..837d7b00c171716c8bed7c735fa4e8d3b4afeb4b 100644 (file)
@@ -167,6 +167,7 @@ void rgw_log_entry::dump(Formatter *f) const
   f->dump_string("user_agent", user_agent);
   f->dump_string("referrer", referrer);
   f->dump_string("bucket_id", bucket_id);
+  f->dump_string("trans_id", trans_id);
 }
 
 void ACLPermission::dump(Formatter *f) const
index 2b0b59eb6fb5ca5e2bf8a922c0553c53e92b736a..19ba62ddc1fe5d6efc5cad737826c5258177feb9 100644 (file)
@@ -273,6 +273,7 @@ void rgw_format_ops_log_entry(struct rgw_log_entry& entry, Formatter *formatter)
     }
     formatter->close_section();
   }
+  formatter->dump_string("trans_id", entry.trans_id);
   formatter->close_section();
 }
 
@@ -426,6 +427,7 @@ int rgw_log_op(RGWRados *store, RGWREST* const rest, struct req_state *s,
 
   entry.error_code = s->err.err_code;
   entry.bucket_id = bucket_id;
+  entry.trans_id = s->trans_id;
 
   bufferlist bl;
   encode(entry, bl);
index 5cd105d7e0127c4cb2e37b996b1d6a58a948c937..9c80410202098a4804c99aaefc3915b92a5a2898 100644 (file)
@@ -34,9 +34,10 @@ struct rgw_log_entry {
   string referrer;
   string bucket_id;
   headers_map x_headers;
+  string trans_id;
 
   void encode(bufferlist &bl) const {
-    ENCODE_START(9, 5, bl);
+    ENCODE_START(10, 5, bl);
     encode(object_owner.id, bl);
     encode(bucket_owner.id, bl);
     encode(bucket, bl);
@@ -59,10 +60,11 @@ struct rgw_log_entry {
     encode(object_owner, bl);
     encode(bucket_owner, bl);
     encode(x_headers, bl);
+    encode(trans_id, bl);
     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::const_iterator &p) {
-    DECODE_START_LEGACY_COMPAT_LEN(8, 5, 5, p);
+    DECODE_START_LEGACY_COMPAT_LEN(10, 5, 5, p);
     decode(object_owner.id, p);
     if (struct_v > 3)
       decode(bucket_owner.id, p);
@@ -108,6 +110,9 @@ struct rgw_log_entry {
     if (struct_v >= 9) {
       decode(x_headers, p);
     }
+    if (struct_v >= 10) {
+      decode(trans_id, p);
+    }
     DECODE_FINISH(p);
   }
   void dump(Formatter *f) const;