summaryrefslogtreecommitdiff
path: root/lib/gitlab_metrics.rb
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-10-16 03:15:34 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-10-16 03:15:34 +0000
commit89bd72d11786f38683fb341a5bd61c28ef3a1ee7 (patch)
treef3264b8693724fa935c5ca4ae30003fed5e89fff /lib/gitlab_metrics.rb
parentc88d80fe74a27f6668d1aaa6db0abc6d2cf693e1 (diff)
parent8cf3f4c7c66580e234d3c2de9c23669cd49b7b5a (diff)
downloadgitlab-shell-89bd72d11786f38683fb341a5bd61c28ef3a1ee7.tar.gz
Merge branch '173-remove-unneeded-binaries' into 'master'
Remove dead Ruby code and unused binaries See merge request gitlab-org/gitlab-shell!346
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