Commit 3ac1d9ad authored by Ryan Cobb's avatar Ryan Cobb

Init http_request_duration_seconds metric

parent 880cb155
......@@ -30,6 +30,8 @@ Gitlab::Application.configure do |config|
config.middleware.insert(1, Gitlab::Metrics::RequestsRackMiddleware)
end
Gitlab::Metrics::RequestsRackMiddleware.initialize_http_request_duration_seconds
Sidekiq.configure_server do |config|
config.on(:startup) do
# webserver metrics are cleaned up in config.ru: `warmup` block
......
......@@ -3,6 +3,9 @@
module Gitlab
module Metrics
class RequestsRackMiddleware
METHODS = %w(delete get head options patch post put trace).freeze
STATUSES = %w(200 301 304 400 401 403 404 500).freeze
def initialize(app)
@app = app
end
......@@ -20,6 +23,14 @@ module Gitlab
{}, [0.05, 0.1, 0.25, 0.5, 0.7, 1, 2.5, 5, 10, 25])
end
def self.initialize_http_request_duration_seconds
METHODS.each do |method|
STATUSES.each do |status|
::Gitlab::Metrics.histogram(:http_request_duration_seconds, 'Request handling execution time').get({ method: method, status: status })
end
end
end
def call(env)
method = env['REQUEST_METHOD'].downcase
started = Time.now.to_f
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment