summaryrefslogtreecommitdiff
path: root/lib/gitlab_metrics.rb
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2019-10-14 16:00:48 +0100
committerNick Thomas <nick@gitlab.com>2019-10-15 07:44:13 +0100
commit18096b5440e0818605add32538751c6be38e8343 (patch)
treeb4aebac9d7f752156ee4ec3d44ee990021a1b295 /lib/gitlab_metrics.rb
parent8db304b4919519bca60a5b18ffe9b88dcde845af (diff)
downloadgitlab-shell-18096b5440e0818605add32538751c6be38e8343.tar.gz
Remove dead Ruby code
Diffstat (limited to 'lib/gitlab_metrics.rb')
-rw-r--r--lib/gitlab_metrics.rb59
1 files changed, 0 insertions, 59 deletions
diff --git a/lib/gitlab_metrics.rb b/lib/gitlab_metrics.rb
deleted file mode 100644
index 917a489..0000000
--- a/lib/gitlab_metrics.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require_relative 'gitlab_config'
-require_relative 'gitlab_logger'
-
-module GitlabMetrics
- module System
- # THREAD_CPUTIME is not supported on OS X
- if Process.const_defined?(:CLOCK_THREAD_CPUTIME_ID)
- def self.cpu_time
- Process.
- clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :millisecond)
- end
- else
- def self.cpu_time
- Process.
- clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID, :millisecond)
- end
- end
-
- # Returns the current monotonic clock time in a given precision.
- #
- # Returns the time as a Fixnum.
- def self.monotonic_time
- if defined?(Process::CLOCK_MONOTONIC)
- Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
- else
- Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
- end
- end
- end
-
- def self.logger
- $logger
- end
-
- # Measures the execution time of a block.
- #
- # Example:
- #
- # GitlabMetrics.measure(:find_by_username_duration) do
- # User.find_by_username(some_username)
- # end
- #
- # name - The name of the field to store the execution time in.
- #
- # Returns the value yielded by the supplied block.
- def self.measure(name)
- start_real = System.monotonic_time
- start_cpu = System.cpu_time
-
- retval = yield
-
- real_time = System.monotonic_time - start_real
- cpu_time = System.cpu_time - start_cpu
-
- logger.debug('metrics', name: name, wall_time: real_time, cpu_time: cpu_time)
-
- retval
- end
-end