]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Transaction Id added in response
authorAbhishek Dixit <dixitabhi@gmail.com>
Mon, 8 Jun 2015 17:29:54 +0000 (22:59 +0530)
committerLoic Dachary <ldachary@redhat.com>
Sun, 30 Aug 2015 17:10:27 +0000 (19:10 +0200)
Signed-off-by: Abhishek Dixit dixitabhi@gmail.com
(cherry picked from commit b711e3124f8f73c17ebd19b38807a1b77f201e44)

Conflicts:
src/rgw/rgw_rest.cc
             the prototype of the end_header( function
             in the context of the diff changed

src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_main.cc
src/rgw/rgw_rest.cc

index f3988cffd34868212586575bca55ed4dd95da984..f5b9a9b2461584e3698f2a3794e73b6c5b5f4b15 100644 (file)
@@ -169,6 +169,18 @@ req_state::~req_state() {
   delete object_acl;
 }
 
+void req_state::gen_trans_id()
+{
+  char buf[256];
+  timeval timetest;
+  gettimeofday(&timetest, NULL);
+  if (strftime(buf, sizeof(buf), "%Y%m%d:%H%M%S",gmtime(&(timetest.tv_sec))) ==  0)
+    return;
+
+  snprintf(buf + strlen(buf), sizeof(buf)-strlen(buf) ,":%03ld", timetest.tv_usec/1000);
+  trans_id = req_id + "-" + buf;
+}
+
 struct str_len {
   const char *str;
   int len;
index 6c7912bd983c726191fd118edc3bc96786fda557..0f46b63f9fdff7c41dd47912e929a7ec1c098127 100644 (file)
@@ -1057,10 +1057,14 @@ struct req_state {
 
    string req_id;
 
+   string trans_id;
+
    req_info info;
 
    req_state(CephContext *_cct, class RGWEnv *e);
    ~req_state();
+
+   void gen_trans_id();
 };
 
 /** Store basic data on an object */
index 2a247e4191f241c98ee5446b99da220c4479c3fe..10a672a4b4b15f06a78406ce1307eb1b219f6b8f 100644 (file)
@@ -556,6 +556,8 @@ static int process_request(RGWRados *store, RGWREST *rest, RGWRequest *req, RGWC
 
   s->req_id = store->unique_id(req->id);
 
+  s->gen_trans_id();
+
   req->log(s, "initializing");
 
   RGWOp *op = NULL;
index d385d6233c72254295f5cb50c7e9b904d9745378..b59d6866a43fd8be1a6a10a1bc5456fbd7335404 100644 (file)
@@ -492,10 +492,22 @@ void dump_start(struct req_state *s)
   }
 }
 
+void dump_trans_id(req_state *s)
+{
+  if (s->prot_flags & RGW_REST_SWIFT) {
+    s->cio->print("X-Trans-Id: ts-%s\r\n", s->trans_id.c_str());
+  }
+  else {
+    s->cio->print("x-amz-request-id: %s\r\n", s->trans_id.c_str());
+  }
+}
+
 void end_header(struct req_state *s, RGWOp *op, const char *content_type, const int64_t proposed_content_length)
 {
   string ctype;
 
+  dump_trans_id(s);
+
   if (op) {
     dump_access_control(s, op);
   }