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 15:36:05 +0200
commita4c8927007499d71a13e1a52c59a0ec36f20a6e0 (patch)
tree20b71dd0d8e0c19701cb6ad9a270ce1a0f0e18fc /lib/gitlab_keys.rb
parentb30d957fe2a85ee9ebb058010020e1c21d256a44 (diff)
downloadgitlab-shell-a4c8927007499d71a13e1a52c59a0ec36f20a6e0.tar.gz
Instrument GitLab Shell and log metrics data to a file
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..46189ae 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}") 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