From c049534da635b3252c564162150b041a2b823860 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 25 May 2016 14:55:23 +0200 Subject: Align class name with field name --- config/initializers/metrics.rb | 2 +- lib/gitlab/middleware/proxy_flight_time.rb | 24 ++++++++++++++++++++++++ lib/gitlab/middleware/proxy_timing.rb | 24 ------------------------ 3 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 lib/gitlab/middleware/proxy_flight_time.rb delete mode 100644 lib/gitlab/middleware/proxy_timing.rb diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb index 2a7979cae54..540e10c1ec1 100644 --- a/config/initializers/metrics.rb +++ b/config/initializers/metrics.rb @@ -12,7 +12,7 @@ if Gitlab::Metrics.enabled? Gitlab::Application.configure do |config| config.middleware.use(Gitlab::Metrics::RackMiddleware) - config.middleware.use(Gitlab::Middleware::ProxyTiming) + config.middleware.use(Gitlab::Middleware::ProxyFlightTime) end Sidekiq.configure_server do |config| diff --git a/lib/gitlab/middleware/proxy_flight_time.rb b/lib/gitlab/middleware/proxy_flight_time.rb new file mode 100644 index 00000000000..042bcdacf8b --- /dev/null +++ b/lib/gitlab/middleware/proxy_flight_time.rb @@ -0,0 +1,24 @@ +# 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 ProxyFlightTime + def initialize(app) + @app = app + end + + def call(env) + trans = Gitlab::Metrics.current_transaction + proxy_start = env['HTTP_GITLAB_WORHORSE_PROXY_START'].presence + if trans && proxy_start + # Time in milliseconds since gitlab-workhorse started the request + trans.set(:proxy_flight_time, Time.now.to_f * 1_000 - proxy_start.to_f / 1_000_000) + end + + @app.call(env) + end + end + end +end diff --git a/lib/gitlab/middleware/proxy_timing.rb b/lib/gitlab/middleware/proxy_timing.rb deleted file mode 100644 index b276eef90a8..00000000000 --- a/lib/gitlab/middleware/proxy_timing.rb +++ /dev/null @@ -1,24 +0,0 @@ -# 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) - trans = Gitlab::Metrics.current_transaction - proxy_start = env['HTTP_GITLAB_WORHORSE_PROXY_START'].presence - if trans && proxy_start - # Time in milliseconds since gitlab-workhorse started the request - trans.set(:proxy_flight_time, Time.now.to_f * 1_000 - proxy_start.to_f / 1_000_000) - end - - @app.call(env) - end - end - end -end -- cgit v1.2.1