summaryrefslogtreecommitdiff
path: root/lib/gitlab_keys.rb
diff options
context:
space:
mode:
authorPaco Guzman <pacoguzmanp@gmail.com>2016-10-10 14:21:28 +0200
committerPaco Guzman <pacoguzmanp@gmail.com>2016-10-11 13:15:28 +0200
commitba44420a2184476fb4c76b3b797b5d1e3e714c8a (patch)
tree9af1b29e5a14497e7c632880c8a04efe08655f24 /lib/gitlab_keys.rb
parentb30d957fe2a85ee9ebb058010020e1c21d256a44 (diff)
downloadgitlab-shell-62-instrument-gitlab-shell.tar.gz
Instrument GitLab Shell and log metrics data to a file62-instrument-gitlab-shell
Diffstat (limited to 'lib/gitlab_keys.rb')
-rw-r--r--lib/gitlab_keys.rb31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/gitlab_keys.rb b/lib/gitlab_keys.rb
index 0eb04eb..7a93b09 100644
--- a/lib/gitlab_keys.rb
+++ b/lib/gitlab_keys.rb
@@ -2,6 +2,7 @@ require 'timeout'
require_relative 'gitlab_config'
require_relative 'gitlab_logger'
+require_relative 'gitlab_metrics'
class GitlabKeys
class KeyError < StandardError ; end
@@ -28,17 +29,25 @@ class GitlabKeys
end
def exec
- case @command
- when 'add-key'; add_key
- when 'batch-add-keys'; batch_add_keys
- when 'rm-key'; rm_key
- when 'list-keys'; puts list_keys
- when 'clear'; clear
- when 'check-permissions'; check_permissions
- else
- $logger.warn "Attempt to execute invalid gitlab-keys command #{@command.inspect}."
- puts 'not allowed'
- false
+ GitlabMetrics.measure("command-#{@command.inspect}") do
+ case @command
+ when 'add-key';
+ add_key
+ when 'batch-add-keys';
+ batch_add_keys
+ when 'rm-key';
+ rm_key
+ when 'list-keys';
+ list_keys
+ when 'clear';
+ clear
+ when 'check-permissions';
+ check_permissions
+ else
+ $logger.warn "Attempt to execute invalid gitlab-keys command #{@command.inspect}."
+ puts 'not allowed'
+ false
+ end
end
end