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
2b7e03cf
Commit
2b7e03cf
authored
Oct 31, 2017
by
micael.bergeron
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reword `targets` to `metric tags`
add changelog
parent
7799a9bc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
+13
-7
app/workers/update_merge_requests_worker.rb
app/workers/update_merge_requests_worker.rb
+4
-3
changelogs/unreleased/35914-merge-request-update-worker-is-slow.yml
.../unreleased/35914-merge-request-update-worker-is-slow.yml
+5
-0
lib/gitlab/metrics/sidekiq_middleware.rb
lib/gitlab/metrics/sidekiq_middleware.rb
+1
-1
spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
+3
-3
No files found.
app/workers/update_merge_requests_worker.rb
View file @
2b7e03cf
...
...
@@ -2,10 +2,10 @@ class UpdateMergeRequestsWorker
include
Sidekiq
::
Worker
include
DedicatedSidekiqQueue
attr_reader
:
targets
# for metrics
tags
attr_reader
:
metrics_
tags
def
initialize
@
target
s
=
{}
@
metrics_tag
s
=
{}
end
def
perform
(
project_id
,
user_id
,
oldrev
,
newrev
,
ref
)
...
...
@@ -15,10 +15,11 @@ class UpdateMergeRequestsWorker
user
=
User
.
find_by
(
id:
user_id
)
return
unless
user
@
target
s
=
{
@
metrics_tag
s
=
{
project_id:
project_id
,
user_id:
user_id
}
MergeRequests
::
RefreshService
.
new
(
project
,
user
).
execute
(
oldrev
,
newrev
,
ref
)
end
end
changelogs/unreleased/35914-merge-request-update-worker-is-slow.yml
0 → 100644
View file @
2b7e03cf
---
title
:
Add metric tagging for sidekiq workers
merge_request
:
15111
author
:
type
:
added
lib/gitlab/metrics/sidekiq_middleware.rb
View file @
2b7e03cf
...
...
@@ -12,7 +12,7 @@ module Gitlab
trans
.
set
(
:sidekiq_queue_duration
,
Time
.
now
.
to_f
-
(
message
[
'enqueued_at'
]
||
message
[
'created_at'
]
||
0
))
trans
.
run
{
yield
}
worker
.
targets
.
each
{
|
name
,
target
|
trans
.
add_tag
(
name
,
target
)
}
if
worker
.
respond_to?
(
:target
s
)
worker
.
metrics_tags
.
each
{
|
tag
,
value
|
trans
.
add_tag
(
tag
,
value
)
}
if
worker
.
respond_to?
(
:metrics_tag
s
)
rescue
Exception
=>
error
# rubocop: disable Lint/RescueException
trans
.
add_event
(
:sidekiq_exception
)
...
...
spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
View file @
2b7e03cf
...
...
@@ -47,11 +47,11 @@ describe Gitlab::Metrics::SidekiqMiddleware do
end
it
'tags the metrics accordingly'
do
ta
rget
s
=
{
one:
1
,
two:
2
}
ta
g
s
=
{
one:
1
,
two:
2
}
worker
=
double
(
:worker
,
class:
double
(
:class
,
name:
'TestWorker'
))
allow
(
worker
).
to
receive
(
:
targets
).
and_return
(
target
s
)
allow
(
worker
).
to
receive
(
:
metrics_tags
).
and_return
(
tag
s
)
ta
rget
s
.
each
do
|
tag
,
value
|
ta
g
s
.
each
do
|
tag
,
value
|
expect_any_instance_of
(
Gitlab
::
Metrics
::
Transaction
).
to
receive
(
:add_tag
)
.
with
(
tag
,
value
)
end
...
...
Alain Takoudjou
@alain.takoudjou
mentioned in commit
7fd3ce41
·
Aug 21, 2018
mentioned in commit
7fd3ce41
mentioned in commit 7fd3ce417f50c6a5f4f4d852514e5f4f03945327
Toggle commit list
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