]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Transaction Id added in response 4900/head
authorAbhishek Dixit <dixitabhi@gmail.com>
Mon, 8 Jun 2015 17:29:54 +0000 (22:59 +0530)
committerAbhishek Dixit <dixitabhi@gmail.com>
Mon, 8 Jun 2015 17:29:54 +0000 (22:59 +0530)
Signed-off-by: Abhishek Dixit dixitabhi@gmail.com
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_main.cc
src/rgw/rgw_rest.cc

index 22581f5a699437906725b7efb787323c7657e2a4..4924feae659d8525447de85901dfa5613d060cbe 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 1baf17862528adfe059ccae86ef7f13e8270505d..42815049b3f164bc62cdcebcab03a3de23991056 100644 (file)
@@ -1061,10 +1061,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 9a8aa5f7b3d6d8ef2291e1b4671d7ffc82643a00..caab642327c5ed2d08d4309de796cc3cab016e7b 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 fffc0036e08f5019fab8c0fc4744152622bb917a..6ed518093a6d173cd0faa88750f00ff44b460520 100644 (file)
@@ -494,11 +494,23 @@ 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,
                bool force_content_type)
 {
   string ctype;
 
+  dump_trans_id(s);
+
   if (op) {
     dump_access_control(s, op);
   }