diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2016-05-24 18:07:41 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2016-05-24 18:07:41 +0300 |
commit | cee07c5919e1a9c792e44c261dd8abfd76a2a993 (patch) | |
tree | b5d7c25f7d7fa5eb003ae81bcd08d2102d0f0042 /lib/gitlab | |
parent | baa9c66057fccefce05b9f01009942fb079fee22 (diff) |
Measure proxy timing: needs influxdb code
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/middleware/proxy_timing.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/gitlab/middleware/proxy_timing.rb b/lib/gitlab/middleware/proxy_timing.rb new file mode 100644 index 00000000000..9094d6b1e7d --- /dev/null +++ b/lib/gitlab/middleware/proxy_timing.rb @@ -0,0 +1,22 @@ +# This Rack middleware is intended to measure the latency between +# gitlab-workhorse forwarding a request to the Rails application and the +# time this middleware is reached. + +module Gitlab + module Middleware + class ProxyTiming + def initialize(app) + @app = app + end + + def call(env) + proxy_start = env['HTTP_GITLAB_WORHORSE_PROXY_START'].to_f / 1_000_000_000 + if proxy_start > 0 + # send measurement + puts "\n\n\n#{(Time.now - proxy_start).to_f}\n\n\n" + end + @app.call(env) + end + end + end +end |