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
0b4a7d65
Commit
0b4a7d65
authored
Nov 14, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework the logging to be simpler and add a threshold
parent
a579bc59
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
app/workers/update_merge_requests_worker.rb
app/workers/update_merge_requests_worker.rb
+12
-6
spec/workers/update_merge_requests_worker_spec.rb
spec/workers/update_merge_requests_worker_spec.rb
+9
-3
No files found.
app/workers/update_merge_requests_worker.rb
View file @
0b4a7d65
...
@@ -2,6 +2,8 @@ class UpdateMergeRequestsWorker
...
@@ -2,6 +2,8 @@ class UpdateMergeRequestsWorker
include
Sidekiq
::
Worker
include
Sidekiq
::
Worker
include
DedicatedSidekiqQueue
include
DedicatedSidekiqQueue
LOG_TIME_THRESHOLD
=
90
# seconds
def
perform
(
project_id
,
user_id
,
oldrev
,
newrev
,
ref
)
def
perform
(
project_id
,
user_id
,
oldrev
,
newrev
,
ref
)
project
=
Project
.
find_by
(
id:
project_id
)
project
=
Project
.
find_by
(
id:
project_id
)
return
unless
project
return
unless
project
...
@@ -14,12 +16,16 @@ class UpdateMergeRequestsWorker
...
@@ -14,12 +16,16 @@ class UpdateMergeRequestsWorker
MergeRequests
::
RefreshService
.
new
(
project
,
user
).
execute
(
oldrev
,
newrev
,
ref
)
MergeRequests
::
RefreshService
.
new
(
project
,
user
).
execute
(
oldrev
,
newrev
,
ref
)
end
end
log_args
=
[
"elapsed=
#{
time
.
real
}
"
]
args_log
=
[
method
(
__method__
).
parameters
.
map
do
|
_
,
p
|
"elapsed=
#{
time
.
real
}
"
,
pname
=
p
.
to_s
"project_id=
#{
project_id
}
"
,
log_args
<<
[
pname
,
binding
.
local_variable_get
(
pname
)].
join
(
'='
)
"user_id=
#{
user_id
}
"
,
end
"oldrev=
#{
oldrev
}
"
,
"newrev=
#{
newrev
}
"
,
"ref=
#{
ref
}
"
].
join
(
','
)
Rails
.
logger
.
info
(
"UpdateMergeRequestsWorker#perform
#{
log_args
.
join
(
','
)
}
"
)
Rails
.
logger
.
info
(
"UpdateMergeRequestsWorker#perform
#{
args_log
}
"
)
if
time
.
real
>
LOG_TIME_THRESHOLD
end
end
end
end
spec/workers/update_merge_requests_worker_spec.rb
View file @
0b4a7d65
...
@@ -24,10 +24,16 @@ describe UpdateMergeRequestsWorker do
...
@@ -24,10 +24,16 @@ describe UpdateMergeRequestsWorker do
perform
perform
end
end
it
'logs performance'
do
context
'when slow'
do
before
do
stub_const
(
"UpdateMergeRequestsWorker::LOG_TIME_THRESHOLD"
,
-
1
)
end
it
'logs debug info'
do
expect
(
Rails
.
logger
).
to
receive
(
:info
).
with
(
a_string_matching
(
/\AUpdateMergeRequestsWorker#perform.*project_id=
#{
project
.
id
}
,user_id=
#{
user
.
id
}
,oldrev=
#{
oldrev
}
,newrev=
#{
newrev
}
,ref=
#{
ref
}
/
))
expect
(
Rails
.
logger
).
to
receive
(
:info
).
with
(
a_string_matching
(
/\AUpdateMergeRequestsWorker#perform.*project_id=
#{
project
.
id
}
,user_id=
#{
user
.
id
}
,oldrev=
#{
oldrev
}
,newrev=
#{
newrev
}
,ref=
#{
ref
}
/
))
perform
perform
end
end
end
end
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