Skip to content

Instantly share code, notes, and snippets.

@weapp
Created December 3, 2015 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weapp/1b2fdf275da333ddb1e9 to your computer and use it in GitHub Desktop.
Save weapp/1b2fdf275da333ddb1e9 to your computer and use it in GitHub Desktop.
RequestId
# http://stackoverflow.com/a/9380164/1171712
module MyFancyApp
class Application < Rails::Application
config.log_tags = [:uuid, :remote_ip]
end
end
# https://github.com/yourkarma/faraday-conductivity
require "faraday/conductivity"
connection = Faraday.new(url: "http://widgets.yourapp.com") do |faraday|
faraday.request :request_id
faraday.adapter Faraday.default_adapter
end
# http://stackoverflow.com/questions/17748735/setting-a-trace-id-in-nginx-load-balancer
# http://ryandlane.com/blog/2014/12/11/using-lua-in-nginx-for-unique-request-ids-and-millisecond-times-in-logs/
# https://gist.github.com/oroce/957791561e26738bf941
http {
server {
set $reqid $pid-$msec-$remote_addr-$request_length-$connection;
if ($http_x_request_id != '') {
set $reqid $http_x_request_id;
}
location / {
proxy_pass http://upstream;
proxy_set_header X-Request-Id $reqid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment