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
4b573816
Commit
4b573816
authored
Jun 10, 2021
by
Piotr Skorupa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add caching for metric instrumentation min/max ids
parent
da3077ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
lib/gitlab/usage/metrics/instrumentations/database_metric.rb
lib/gitlab/usage/metrics/instrumentations/database_metric.rb
+18
-2
No files found.
lib/gitlab/usage/metrics/instrumentations/database_metric.rb
View file @
4b573816
...
...
@@ -16,14 +16,20 @@ module Gitlab
# end
class
<<
self
def
start
(
&
block
)
return
@metric_start
&
.
call
unless
block_given?
@metric_start
=
block
end
def
finish
(
&
block
)
return
@metric_finish
&
.
call
unless
block_given?
@metric_finish
=
block
end
def
relation
(
&
block
)
return
@metric_relation
&
.
call
unless
block_given?
@metric_relation
=
block
end
...
...
@@ -36,11 +42,21 @@ module Gitlab
end
def
value
key_name
=
"metric_instrumentation/
#{
relation
.
table_name
}
"
start
=
Rails
.
cache
.
fetch
(
"
#{
key_name
}
_minimum_id"
,
expires_in:
1
.
day
)
do
self
.
class
.
start
end
finish
=
Rails
.
cache
.
fetch
(
"
#{
key_name
}
_maximum_id"
,
expires_in:
1
.
day
)
do
self
.
class
.
finish
end
method
(
self
.
class
.
metric_operation
)
.
call
(
relation
,
self
.
class
.
column
,
start:
s
elf
.
class
.
metric_start
&
.
call
,
finish:
self
.
class
.
metric_finish
&
.
call
)
start:
s
tart
,
finish:
finish
)
end
def
to_sql
...
...
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