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| ...@@ -30,6 +30,8 @@ Gitlab::Application.configure do |config|
config.middleware.insert(1, Gitlab::Metrics::RequestsRackMiddleware) config.middleware.insert(1, Gitlab::Metrics::RequestsRackMiddleware)
end end
Gitlab::Metrics::RequestsRackMiddleware.initialize_http_request_duration_seconds
Sidekiq.configure_server do |config| Sidekiq.configure_server do |config|
config.on(:startup) do config.on(:startup) do
# webserver metrics are cleaned up in config.ru: `warmup` block # webserver metrics are cleaned up in config.ru: `warmup` block
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
module Gitlab module Gitlab
module Metrics module Metrics
class RequestsRackMiddleware 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) def initialize(app)
@app = app @app = app
end end
...@@ -20,6 +23,14 @@ module Gitlab ...@@ -20,6 +23,14 @@ module Gitlab
{}, [0.05, 0.1, 0.25, 0.5, 0.7, 1, 2.5, 5, 10, 25]) {}, [0.05, 0.1, 0.25, 0.5, 0.7, 1, 2.5, 5, 10, 25])
end 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) def call(env)
method = env['REQUEST_METHOD'].downcase method = env['REQUEST_METHOD'].downcase
started = Time.now.to_f 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