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
4af24c69
Commit
4af24c69
authored
Apr 27, 2021
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put metrics in table in LimitedCapacity::Worker
I think this makes the code easier to read.
parent
4313ef4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
21 deletions
+11
-21
app/workers/concerns/limited_capacity/worker.rb
app/workers/concerns/limited_capacity/worker.rb
+11
-21
No files found.
app/workers/concerns/limited_capacity/worker.rb
View file @
4af24c69
...
...
@@ -110,12 +110,12 @@ module LimitedCapacity
def
report_prometheus_metrics
(
*
args
)
report_running_jobs_metrics
remaining_work_gauge
.
set
(
prometheus_labels
,
remaining_work_count
(
*
args
))
max_running_jobs_gauge
.
set
(
prometheus_labels
,
max_running_jobs
)
set_metric
(
:remaining_work_gauge
,
remaining_work_count
(
*
args
))
set_metric
(
:max_running_jobs_gauge
,
max_running_jobs
)
end
def
report_running_jobs_metrics
running_jobs_gauge
.
set
(
prometheus_labels
,
running_jobs_count
)
set_metric
(
:running_jobs_gauge
,
running_jobs_count
)
end
def
required_jobs_count
(
*
args
)
...
...
@@ -144,26 +144,16 @@ module LimitedCapacity
self
.
class
.
perform_async
(
*
args
)
end
def
running_jobs_gauge
strong_memoize
(
:running_jobs_gauge
)
do
Gitlab
::
Metrics
.
gauge
(
:limited_capacity_worker_running_jobs
,
'Number of running jobs'
)
def
set_metric
(
name
,
value
)
metrics
=
strong_memoize
(
:metrics
)
do
{
running_jobs_gauge:
Gitlab
::
Metrics
.
gauge
(
:limited_capacity_worker_running_jobs
,
'Number of running jobs'
),
max_running_jobs_gauge:
Gitlab
::
Metrics
.
gauge
(
:limited_capacity_worker_max_running_jobs
,
'Maximum number of running jobs'
),
remaining_work_gauge:
Gitlab
::
Metrics
.
gauge
(
:limited_capacity_worker_remaining_work_count
,
'Number of jobs waiting to be enqueued'
)
}
end
end
def
max_running_jobs_gauge
strong_memoize
(
:max_running_jobs_gauge
)
do
Gitlab
::
Metrics
.
gauge
(
:limited_capacity_worker_max_running_jobs
,
'Maximum number of running jobs'
)
end
end
def
remaining_work_gauge
strong_memoize
(
:remaining_work_gauge
)
do
Gitlab
::
Metrics
.
gauge
(
:limited_capacity_worker_remaining_work_count
,
'Number of jobs waiting to be enqueued'
)
end
end
def
prometheus_labels
{
worker:
self
.
class
.
name
}
metrics
[
name
].
set
({
worker:
self
.
class
.
name
},
value
)
end
end
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