Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-09 07:33:20 +0300
committerStan Hu <stanhu@gmail.com>2019-08-09 11:08:32 +0300
commita74396dcc5e372c0b6a23fd47db22ebbeb8386d7 (patch)
tree20492308e8d7acd6658fc3c80a6e98fedbd79be1 /lib/gitlab/instrumentation_helper.rb
parentbbf639c43d689bd63a32ef7a60bdf83d3bd329bf (diff)
Add Gitaly and Rugged call timing in Sidekiq logs
This will help identify Sidekiq jobs that invoke excessive number of filesystem access. The timing data is stored in `RequestStore`, but this is only active within the middleware and is not directly accessible to the Sidekiq logger. However, it is possible for the middleware to modify the job hash to pass this data along to the logger.
Diffstat (limited to 'lib/gitlab/instrumentation_helper.rb')
-rw-r--r--lib/gitlab/instrumentation_helper.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitlab/instrumentation_helper.rb b/lib/gitlab/instrumentation_helper.rb
new file mode 100644
index 00000000000..e6a5facb2a5
--- /dev/null
+++ b/lib/gitlab/instrumentation_helper.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module InstrumentationHelper
+ extend self
+
+ KEYS = %i(gitaly_calls gitaly_duration rugged_calls rugged_duration_ms).freeze
+
+ def add_instrumentation_data(payload)
+ gitaly_calls = Gitlab::GitalyClient.get_request_count
+
+ if gitaly_calls > 0
+ payload[:gitaly_calls] = gitaly_calls
+ payload[:gitaly_duration] = Gitlab::GitalyClient.query_time_ms
+ end
+
+ rugged_calls = Gitlab::RuggedInstrumentation.query_count
+
+ if rugged_calls > 0
+ payload[:rugged_calls] = rugged_calls
+ payload[:rugged_duration_ms] = Gitlab::RuggedInstrumentation.query_time_ms
+ end
+ end
+ end
+end