summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-11-16 13:33:17 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-11-16 13:33:17 +0000
commit9955111c4566563a2975279598bec2e76a2c21a3 (patch)
treeaa4278b09bab2921b4297f06e031d54c21140f14
parented59fbc3b72146cd9c4e040c64150c8b961c7d42 (diff)
parent265df408f9082cc9f40f0cf1b7ae1a5e3601fda5 (diff)
downloadgitlab-shell-9955111c4566563a2975279598bec2e76a2c21a3.tar.gz
Merge branch 'more-instrumentation-down-the-pipeline' into 'master'
Add instrumentation to push hooks See merge request !106
-rw-r--r--CHANGELOG3
-rw-r--r--lib/gitlab_access.rb5
-rw-r--r--lib/gitlab_custom_hook.rb7
-rw-r--r--lib/gitlab_post_receive.rb9
4 files changed, 18 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 30fb166..7f899ca 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v4.0.1
+ - Add instrumentation to push hooks
+
v4.0.0
- Use full repository path for API calls
diff --git a/lib/gitlab_access.rb b/lib/gitlab_access.rb
index ab431bf..34cf4b1 100644
--- a/lib/gitlab_access.rb
+++ b/lib/gitlab_access.rb
@@ -2,6 +2,7 @@ require_relative 'gitlab_init'
require_relative 'gitlab_net'
require_relative 'gitlab_access_status'
require_relative 'names_helper'
+require_relative 'gitlab_metrics'
require 'json'
class GitlabAccess
@@ -20,7 +21,9 @@ class GitlabAccess
end
def exec
- status = api.check_access('git-receive-pack', @repo_path, @actor, @changes, @protocol)
+ status = GitlabMetrics.measure('check-access:git-receive-pack') do
+ api.check_access('git-receive-pack', @repo_path, @actor, @changes, @protocol)
+ end
raise AccessDeniedError, status.message unless status.allowed?
diff --git a/lib/gitlab_custom_hook.rb b/lib/gitlab_custom_hook.rb
index 4edb48b..6f2e901 100644
--- a/lib/gitlab_custom_hook.rb
+++ b/lib/gitlab_custom_hook.rb
@@ -1,4 +1,5 @@
require 'open3'
+require_relative 'gitlab_metrics'
class GitlabCustomHook
attr_reader :vars
@@ -11,21 +12,21 @@ class GitlabCustomHook
hook = hook_file('pre-receive', repo_path)
return true if hook.nil?
- call_receive_hook(hook, changes)
+ GitlabMetrics.measure("pre-receive-hook") { call_receive_hook(hook, changes) }
end
def post_receive(changes, repo_path)
hook = hook_file('post-receive', repo_path)
return true if hook.nil?
- call_receive_hook(hook, changes)
+ GitlabMetrics.measure("post-receive-hook") { call_receive_hook(hook, changes) }
end
def update(ref_name, old_value, new_value, repo_path)
hook = hook_file('update', repo_path)
return true if hook.nil?
- system(vars, hook, ref_name, old_value, new_value)
+ GitlabMetrics.measure("update-hook") { system(vars, hook, ref_name, old_value, new_value) }
end
private
diff --git a/lib/gitlab_post_receive.rb b/lib/gitlab_post_receive.rb
index 3af2b38..ffa6a15 100644
--- a/lib/gitlab_post_receive.rb
+++ b/lib/gitlab_post_receive.rb
@@ -1,6 +1,7 @@
require_relative 'gitlab_init'
require_relative 'gitlab_net'
require_relative 'gitlab_reference_counter'
+require_relative 'gitlab_metrics'
require 'json'
require 'base64'
require 'securerandom'
@@ -21,14 +22,18 @@ class GitlabPostReceive
result = update_redis
begin
- broadcast_message = api.broadcast_message
+ broadcast_message = GitlabMetrics.measure("broadcast-message") do
+ api.broadcast_message
+ end
if broadcast_message.has_key?("message")
puts
print_broadcast_message(broadcast_message["message"])
end
- merge_request_urls = api.merge_request_urls(@repo_path, @changes)
+ merge_request_urls = GitlabMetrics.measure("merge-request-urls") do
+ api.merge_request_urls(@repo_path, @changes)
+ end
print_merge_request_links(merge_request_urls)
rescue GitlabNet::ApiUnreachableError
nil