Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
78737f81
Commit
78737f81
authored
Feb 24, 2022
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add caller_id to Etag cache hits
parent
effccda7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
+16
-5
lib/gitlab/etag_caching/middleware.rb
lib/gitlab/etag_caching/middleware.rb
+4
-1
lib/gitlab/etag_caching/router.rb
lib/gitlab/etag_caching/router.rb
+4
-3
spec/lib/gitlab/etag_caching/middleware_spec.rb
spec/lib/gitlab/etag_caching/middleware_spec.rb
+2
-1
spec/lib/gitlab/etag_caching/router/rails_spec.rb
spec/lib/gitlab/etag_caching/router/rails_spec.rb
+6
-0
No files found.
lib/gitlab/etag_caching/middleware.rb
View file @
78737f81
...
...
@@ -67,7 +67,10 @@ module Gitlab
add_instrument_for_cache_hit
(
status_code
,
route
,
request
)
Gitlab
::
ApplicationContext
.
push
(
feature_category:
route
.
feature_category
)
Gitlab
::
ApplicationContext
.
push
(
feature_category:
route
.
feature_category
,
caller_id:
route
.
caller_id
)
new_headers
=
{
'ETag'
=>
etag
,
...
...
lib/gitlab/etag_caching/router.rb
View file @
78737f81
...
...
@@ -3,23 +3,24 @@
module
Gitlab
module
EtagCaching
module
Router
Route
=
Struct
.
new
(
:r
egexp
,
:name
,
:feature_category
,
:router
)
do
Route
=
Struct
.
new
(
:r
outer
,
:regexp
,
:name
,
:feature_category
,
:caller_id
)
do
delegate
:match
,
to: :regexp
delegate
:cache_key
,
to: :router
end
module
Helpers
def
build_route
(
attrs
)
EtagCaching
::
Router
::
Route
.
new
(
*
attrs
,
self
)
EtagCaching
::
Router
::
Route
.
new
(
self
,
*
attrs
)
end
def
build_rails_route
(
attrs
)
regexp
,
name
,
controller
,
action_name
=
*
attrs
EtagCaching
::
Router
::
Route
.
new
(
self
,
regexp
,
name
,
controller
.
feature_category_for_action
(
action_name
).
to_s
,
self
controller
.
endpoint_id_for_action
(
action_name
).
to_s
)
end
end
...
...
spec/lib/gitlab/etag_caching/middleware_spec.rb
View file @
78737f81
...
...
@@ -174,7 +174,8 @@ RSpec.describe Gitlab::EtagCaching::Middleware, :clean_gitlab_redis_shared_state
it
"pushes route's feature category to the context"
do
expect
(
Gitlab
::
ApplicationContext
).
to
receive
(
:push
).
with
(
feature_category:
'team_planning'
feature_category:
'team_planning'
,
caller_id:
'Projects::NotesController#index'
)
_
,
_
,
_
=
middleware
.
call
(
build_request
(
path
,
if_none_match
))
...
...
spec/lib/gitlab/etag_caching/router/rails_spec.rb
View file @
78737f81
...
...
@@ -114,6 +114,12 @@ RSpec.describe Gitlab::EtagCaching::Router::Rails do
end
end
it
'has a caller_id for every route'
,
:aggregate_failures
do
described_class
::
ROUTES
.
each
do
|
route
|
expect
(
route
.
caller_id
).
to
include
(
'#'
),
"
#{
route
.
name
}
has caller_id
#{
route
.
caller_id
}
, which is not valid"
end
end
def
match_route
(
path
)
described_class
.
match
(
double
(
path_info:
path
))
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment