13558: add req_id as a tag to Rails.logger
authorJoshua C. Randall <jcrandall@alum.mit.edu>
Fri, 1 Jun 2018 18:53:29 +0000 (18:53 +0000)
committerJoshua C. Randall <jcrandall@alum.mit.edu>
Thu, 28 Jun 2018 16:25:09 +0000 (16:25 +0000)
closes #13558

Arvados-DCO-1.1-Signed-off-by: Joshua C. Randall <jcrandall@alum.mit.edu>

services/api/app/controllers/application_controller.rb

index ba7c07d27266f26ef3bcdbcfc01940d406cec9b1..71176056fa3f24c5340796d2ef2fe20069acd666 100644 (file)
@@ -382,7 +382,9 @@ class ApplicationController < ActionController::Base
       req_id = "req-" + Random::DEFAULT.rand(2**128).to_s(36)[0..19]
     end
     response.headers['X-Request-Id'] = Thread.current[:request_id] = req_id
-    yield
+    Rails.logger.tagged(req_id) do
+      yield
+    end
     Thread.current[:request_id] = nil
   end