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
e27e5f97
Commit
e27e5f97
authored
Apr 14, 2022
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Detect unsupported keyset queries with Prometheus
parent
e377606b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
lib/gitlab/graphql/pagination/keyset/generic_keyset_pagination.rb
...ab/graphql/pagination/keyset/generic_keyset_pagination.rb
+16
-1
spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb
spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb
+11
-0
No files found.
lib/gitlab/graphql/pagination/keyset/generic_keyset_pagination.rb
View file @
e27e5f97
...
...
@@ -73,10 +73,25 @@ module Gitlab
strong_memoize
(
:generic_keyset_pagination_items
)
do
rebuilt_items_with_keyset_order
,
success
=
Gitlab
::
Pagination
::
Keyset
::
SimpleOrderBuilder
.
build
(
original_items
)
success
?
rebuilt_items_with_keyset_order
:
original_items
if
success
rebuilt_items_with_keyset_order
else
if
original_items
.
is_a?
(
ActiveRecord
::
Relation
)
old_keyset_pagination_usage
.
increment
({
model:
original_items
.
model
.
to_s
})
end
original_items
end
end
end
def
old_keyset_pagination_usage
@old_keyset_pagination_usage
||=
Gitlab
::
Metrics
.
counter
(
:old_keyset_pagination_usage
,
'The number of times the old keyset pagination code was used'
)
end
end
end
end
end
...
...
spec/lib/gitlab/graphql/pagination/keyset/connection_spec.rb
View file @
e27e5f97
...
...
@@ -77,6 +77,17 @@ RSpec.describe Gitlab::Graphql::Pagination::Keyset::Connection do
expect
(
decoded_cursor
(
cursor
)).
to
eq
(
'id'
=>
project
.
id
.
to_s
)
end
context
'when SimpleOrderBuilder cannot build keyset paginated query'
do
it
'increments the `old_keyset_pagination_usage` counter'
,
:prometheus
do
expect
(
Gitlab
::
Pagination
::
Keyset
::
SimpleOrderBuilder
).
to
receive
(
:build
).
and_return
([
false
,
nil
])
decoded_cursor
(
cursor
)
counter
=
Gitlab
::
Metrics
.
registry
.
get
(
:old_keyset_pagination_usage
)
expect
(
counter
.
get
(
model:
'Project'
)).
to
eq
(
1
)
end
end
context
'when an order is specified'
do
let
(
:nodes
)
{
Project
.
order
(
:updated_at
)
}
...
...
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