diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-04 19:13:19 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-09 14:29:10 +0100 |
commit | dec3e4ce64df5f71a7cba7734cada1baa79242cd (patch) | |
tree | f9eb65a953ded11859926010956d19d40bad4d32 /lib/gitlab/sherlock/file_sample.rb | |
parent | bd54bf7a798c06751d464ac3af1fef0e7ee90ea6 (diff) | |
download | gitlab-ce-dec3e4ce64df5f71a7cba7734cada1baa79242cd.tar.gz |
Added Sherlock, a custom profiling tool for GitLab
Sherlock will be a new GitLab specific tool for measuring the
performance of Rails requests (and SideKiq jobs at some point). Some of
the things that are currently tracked:
* SQL queries along with their timings, backtraces and query plans
(using "EXPLAIN ANALYZE" for PostgreSQL and regular "EXPLAIN" for
MySQL)
* Timings of application files (including views) on a per line basis
* Some meta data such as the request method, path, total duration, etc
More tracking (e.g. Rugged or gitlab-shell timings) might be added in
the future.
Sherlock will replace any existing tools we have used so far (e.g.
active_record_query_trace and rack-mini-profiler), hence the
corresponding Gems have been removed from the Gemfile.
Sherlock can be enabled by starting Rails as following:
ENABLE_SHERLOCK=1 bundle exec rails s
Recorded transactions can be found at `/sherlock/transactions`.
Diffstat (limited to 'lib/gitlab/sherlock/file_sample.rb')
-rw-r--r-- | lib/gitlab/sherlock/file_sample.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/gitlab/sherlock/file_sample.rb b/lib/gitlab/sherlock/file_sample.rb new file mode 100644 index 00000000000..7a220de9abc --- /dev/null +++ b/lib/gitlab/sherlock/file_sample.rb @@ -0,0 +1,27 @@ +module Gitlab + module Sherlock + class FileSample + attr_reader :id, :file, :line_samples, :events, :duration + + def initialize(file, line_samples, duration, events) + @id = SecureRandom.uuid + @file = file + @line_samples = line_samples + @duration = duration + @events = events + end + + def relative_path + @relative_path ||= @file.gsub(/^#{Rails.root.to_s}\/?/, '') + end + + def to_param + @id + end + + def source + @source ||= File.read(@file) + end + end + end +end |