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>2023-01-20 21:10:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-20 21:10:05 +0300
commitcc4e1c884cd6b8782fb6a247d840a2d1c7f4603e (patch)
tree8a54c659b82873efafe04887708140785caea153 /lib/gitlab/etag_caching
parent709948b7a69597b1efe24df9b0f388cc0b493dd9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/etag_caching')
-rw-r--r--lib/gitlab/etag_caching/middleware.rb13
-rw-r--r--lib/gitlab/etag_caching/router.rb30
-rw-r--r--lib/gitlab/etag_caching/router/graphql.rb2
-rw-r--r--lib/gitlab/etag_caching/router/rails.rb2
4 files changed, 31 insertions, 16 deletions
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb
index f6431483a15..7aabf699a59 100644
--- a/lib/gitlab/etag_caching/middleware.rb
+++ b/lib/gitlab/etag_caching/middleware.rb
@@ -65,13 +65,15 @@ module Gitlab
status_code = Gitlab::PollingInterval.polling_enabled? ? 304 : 429
- add_instrument_for_cache_hit(status_code, route, request)
-
Gitlab::ApplicationContext.push(
feature_category: route.feature_category,
- caller_id: route.caller_id
+ caller_id: route.caller_id,
+ remote_ip: request.remote_ip
)
+ request.env[Gitlab::Metrics::RequestsRackMiddleware::REQUEST_URGENCY_KEY] = route.urgency
+ add_instrument_for_cache_hit(status_code, route, request)
+
new_headers = {
'ETag' => etag,
'X-Gitlab-From-Cache' => 'true'
@@ -102,7 +104,10 @@ module Gitlab
format: request.format.ref,
method: request.request_method,
path: request.filtered_path,
- status: status
+ status: status,
+ metadata: Gitlab::ApplicationContext.current,
+ request_urgency: route.urgency.name,
+ target_duration_s: route.urgency.duration
}
ActiveSupport::Notifications.instrument(
diff --git a/lib/gitlab/etag_caching/router.rb b/lib/gitlab/etag_caching/router.rb
index 684afc6762a..754b54fda81 100644
--- a/lib/gitlab/etag_caching/router.rb
+++ b/lib/gitlab/etag_caching/router.rb
@@ -3,24 +3,34 @@
module Gitlab
module EtagCaching
module Router
- Route = Struct.new(:router, :regexp, :name, :feature_category, :caller_id) do
+ Route = Struct.new(:router, :regexp, :name, :feature_category, :caller_id, :urgency, keyword_init: true) do
delegate :match, to: :regexp
delegate :cache_key, to: :router
end
module Helpers
- def build_route(attrs)
- EtagCaching::Router::Route.new(self, *attrs)
+ def build_graphql_route(regexp, name, feature_category)
+ EtagCaching::Router::Route.new(
+ router: self,
+ regexp: regexp,
+ name: name,
+ feature_category: feature_category,
+ # This information can be loaded from the graphql query, but is not
+ # included yet
+ # https://gitlab.com/groups/gitlab-com/gl-infra/-/epics/665
+ caller_id: nil,
+ urgency: Gitlab::EndpointAttributes::DEFAULT_URGENCY
+ )
end
- def build_rails_route(attrs)
- regexp, name, controller, action_name = *attrs
+ def build_rails_route(regexp, name, controller, action_name)
EtagCaching::Router::Route.new(
- self,
- regexp,
- name,
- controller.feature_category_for_action(action_name).to_s,
- controller.endpoint_id_for_action(action_name).to_s
+ router: self,
+ regexp: regexp,
+ name: name,
+ feature_category: controller.feature_category_for_action(action_name).to_s,
+ caller_id: controller.endpoint_id_for_action(action_name).to_s,
+ urgency: controller.urgency_for_action(action_name)
)
end
end
diff --git a/lib/gitlab/etag_caching/router/graphql.rb b/lib/gitlab/etag_caching/router/graphql.rb
index 1f56670ee7f..7a0fb2ac269 100644
--- a/lib/gitlab/etag_caching/router/graphql.rb
+++ b/lib/gitlab/etag_caching/router/graphql.rb
@@ -23,7 +23,7 @@ module Gitlab
'on_demand_scans',
'dynamic_application_security_testing'
]
- ].map(&method(:build_route)).freeze
+ ].map { |attrs| build_graphql_route(*attrs) }.freeze
def self.match(request)
return unless request.path_info == graphql_api_path
diff --git a/lib/gitlab/etag_caching/router/rails.rb b/lib/gitlab/etag_caching/router/rails.rb
index d80c003fe53..2924370f494 100644
--- a/lib/gitlab/etag_caching/router/rails.rb
+++ b/lib/gitlab/etag_caching/router/rails.rb
@@ -104,7 +104,7 @@ module Gitlab
::Projects::MergeRequests::ContentController,
:cached_widget
]
- ].map(&method(:build_rails_route)).freeze
+ ].map { |attrs| build_rails_route(*attrs) }.freeze
# Overridden in EE to add more routes
def self.all_routes