diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-15 12:20:15 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-11-15 12:20:15 +0300 |
commit | 5c600294a26ae8df430f64d73753d6eaadd9e427 (patch) | |
tree | 28b5e0ff86cf7adb9cd435723111e8c33c4794ff /app | |
parent | 068f9df2bdf8b758360dbb81a449986b2636bc3b (diff) | |
parent | 45c373caf570cee7ef3b51d0709c01cc3df3a818 (diff) |
Merge branch 'update-merge-worker-metrics' into 'master'
Add simple logging to UpdateMergeRequestsWorker#perform
See merge request gitlab-org/gitlab-ce!15360
Diffstat (limited to 'app')
-rw-r--r-- | app/workers/update_merge_requests_worker.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/app/workers/update_merge_requests_worker.rb b/app/workers/update_merge_requests_worker.rb index 89ae17cef37..afc47fc63d6 100644 --- a/app/workers/update_merge_requests_worker.rb +++ b/app/workers/update_merge_requests_worker.rb @@ -2,6 +2,8 @@ class UpdateMergeRequestsWorker include Sidekiq::Worker include DedicatedSidekiqQueue + LOG_TIME_THRESHOLD = 90 # seconds + def perform(project_id, user_id, oldrev, newrev, ref) project = Project.find_by(id: project_id) return unless project @@ -9,6 +11,20 @@ class UpdateMergeRequestsWorker user = User.find_by(id: user_id) return unless user - MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref) + # TODO: remove this benchmarking when we have rich logging + time = Benchmark.measure do + MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref) + end + + args_log = [ + "elapsed=#{time.real}", + "project_id=#{project_id}", + "user_id=#{user_id}", + "oldrev=#{oldrev}", + "newrev=#{newrev}", + "ref=#{ref}" + ].join(',') + + Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD end end |