diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 15:10:04 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-06 15:10:04 +0000 |
commit | f3b1e07903a7f509b11ad7cf188fac46d98f77f6 (patch) | |
tree | a6fa5e65d83d94334387952f1f526ed438604408 /lib | |
parent | ba174c982f40d71a87fd511b091753807174f7e7 (diff) | |
download | gitlab-ce-f3b1e07903a7f509b11ad7cf188fac46d98f77f6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics/requests_rack_middleware.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/gitlab/metrics/requests_rack_middleware.rb b/lib/gitlab/metrics/requests_rack_middleware.rb index b57f9a19f8e..15db3999fa4 100644 --- a/lib/gitlab/metrics/requests_rack_middleware.rb +++ b/lib/gitlab/metrics/requests_rack_middleware.rb @@ -15,6 +15,8 @@ module Gitlab "report" => %w(404) }.freeze + HEALTH_ENDPOINT = /^\/-\/(liveness|readiness|health|metrics)\/?$/.freeze + def initialize(app) @app = app end @@ -32,6 +34,10 @@ module Gitlab {}, [0.05, 0.1, 0.25, 0.5, 0.7, 1, 2.5, 5, 10, 25]) end + def self.http_health_requests_total + @http_health_requests_total ||= ::Gitlab::Metrics.counter(:http_health_requests_total, 'Health endpoint request count') + end + def self.initialize_http_request_duration_seconds HTTP_METHODS.each do |method, statuses| statuses.each do |status| @@ -43,8 +49,13 @@ module Gitlab def call(env) method = env['REQUEST_METHOD'].downcase started = Time.now.to_f + begin - RequestsRackMiddleware.http_request_total.increment(method: method) + if health_endpoint?(env['PATH_INFO']) + RequestsRackMiddleware.http_health_requests_total.increment(method: method) + else + RequestsRackMiddleware.http_request_total.increment(method: method) + end status, headers, body = @app.call(env) @@ -57,6 +68,12 @@ module Gitlab raise end end + + def health_endpoint?(path) + return false if path.blank? + + HEALTH_ENDPOINT.match?(CGI.unescape(path)) + end end end end |