Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 03:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-24 03:08:51 +0300
commit1ce6af4aad0107b6d604f89a3c0b530476a10165 (patch)
tree4956b0d395cd9232bca14f83daca3cd8616cc842 /lib/gitlab/etag_caching
parent24256212ea84e6fb6509f6fb317a2d2bac3d0d06 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/etag_caching')
-rw-r--r--lib/gitlab/etag_caching/middleware.rb21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb
index a11d6b66409..303e1a23e6b 100644
--- a/lib/gitlab/etag_caching/middleware.rb
+++ b/lib/gitlab/etag_caching/middleware.rb
@@ -18,7 +18,7 @@ module Gitlab
if_none_match = env['HTTP_IF_NONE_MATCH']
if if_none_match == etag
- handle_cache_hit(etag, route)
+ handle_cache_hit(etag, route, request)
else
track_cache_miss(if_none_match, cached_value_present, route)
@@ -47,11 +47,13 @@ module Gitlab
%Q{W/"#{value}"}
end
- def handle_cache_hit(etag, route)
+ def handle_cache_hit(etag, route, request)
track_event(:etag_caching_cache_hit, route)
status_code = Gitlab::PollingInterval.polling_enabled? ? 304 : 429
+ add_instrument_for_cache_hit(status_code, route, request)
+
[status_code, { 'ETag' => etag, 'X-Gitlab-From-Cache' => 'true' }, []]
end
@@ -68,6 +70,21 @@ module Gitlab
def track_event(name, route)
Gitlab::Metrics.add_event(name, endpoint: route.name)
end
+
+ def add_instrument_for_cache_hit(status, route, request)
+ payload = {
+ etag_route: route.name,
+ params: request.filtered_parameters,
+ headers: request.headers,
+ format: request.format.ref,
+ method: request.request_method,
+ path: request.filtered_path,
+ status: status
+ }
+
+ ActiveSupport::Notifications.instrument(
+ "process_action.action_controller", payload)
+ end
end
end
end