Module: GreenHat::Shell::Faststats
- Defined in:
- lib/greenhat/shell/faststats.rb
Overview
Logs
Class Method Summary collapse
-
.default(raw, _other = nil) ⇒ Object
Vanilla Fast Stats.
-
.errors(raw) ⇒ Object
===== [ Fast Stats - Errors ] ==================== ========================================================================.
-
.faststats_installation ⇒ Object
rubocop:enable Metrics/MethodLength).
-
.help ⇒ Object
rubocop:disable Metrics/MethodLength).
-
.list(args = []) ⇒ Object
List Files Helpers.
- .ls(args = []) ⇒ Object
-
.top(raw) ⇒ Object
===== [ Fast Stats - Top ] ==================== ————————————————- Options: –display, value,perc,both Show percentage of totals, actual durations, or both.
Class Method Details
.default(raw, _other = nil) ⇒ Object
Vanilla Fast Stats
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/greenhat/shell/faststats.rb', line 110 def self.default(raw, _other = nil) unless TTY::Which.exist? 'fast-stats' faststats_installation return false end files, flags, cmd = ShellHelper::Faststats.parse(raw) LogBot.debug('FastStats CMD', cmd) if ENV['DEBUG'] results = ShellHelper.file_process(files) do |file| [ file.friendly_name, `fast-stats #{cmd} #{file.file}`.split("\n"), "\n" ] end ShellHelper.show(results.flatten, flags) end |
.errors(raw) ⇒ Object
[ Fast Stats - Errors ] ====================
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/greenhat/shell/faststats.rb', line 165 def self.errors(raw) unless TTY::Which.exist? 'fast-stats' faststats_installation return false end # Add Color Output raw.push '--color-output' files, flags, cmd = ShellHelper::Faststats.parse(raw) LogBot.debug('FastStats CMD', cmd) if ENV['DEBUG'] results = ShellHelper.file_process(files) do |file| [ file.friendly_name, `fast-stats errors #{cmd} #{file.file}`.split("\n"), "\n" ] end ShellHelper.show(results.flatten, flags) end |
.faststats_installation ⇒ Object
rubocop:enable Metrics/MethodLength)
70 71 72 73 74 75 |
# File 'lib/greenhat/shell/faststats.rb', line 70 def self.faststats_installation puts "#{'Unable to find'.pastel(:red)} #{'fast-stats'.pastel(:blue)}" puts ' Release Downloads here' puts ' - https://gitlab.com/gitlab-com/support/toolbox/fast-stats/-/releases'.pastel(:yellow) puts '' end |
.help ⇒ Object
rubocop:disable Metrics/MethodLength)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/greenhat/shell/faststats.rb', line 7 def self.help puts "\u2500".pastel(:cyan) * 25 puts "Gimme #{'Performance Stats'.pastel(:yellow)}" puts "\u2500".pastel(:cyan) * 25 puts 'General'.pastel(:blue) puts " Any double dash arguments (e.g. #{'--color-output'.pastel(:green)}) are passed directly to fast-stats" puts " See #{'`fast-stats --help`'.pastel(:bright_black)} for all available options" puts puts 'Common Options'.pastel(:blue) puts ' --raw'.pastel(:green) puts ' Do not use less/paging' puts ' --search'.pastel(:green) puts ' Case-insensitive search of controller/method/worker field' puts ' --sort'.pastel(:green) puts ' count,fail,max,median,min,p95,p99,rps,score' puts ' --limit'.pastel(:green) puts ' The number of rows to print' puts ' --verbose'.pastel(:green) puts ' Prints the component details of the maximum, P99, P95, and median events by total duration for each' puts puts 'Commands'.pastel(:blue) puts 'ls'.pastel(:green) puts ' List available files' puts ' Options' puts ' -a, --all, show all files including source' puts puts '<file names+>'.pastel(:green) puts ' Print any file names' puts ' Ex: `gitaly/current`' puts ' Ex: `gitlab-rails/api_json.log gitlab-rails/production_json.log --raw`' puts puts 'top'.pastel(:green) puts ' Print a summary of top items in a category' puts puts 'errors'.pastel(:green) puts ' Show summary of errors captured in log' puts puts 'Examples'.pastel(:blue) puts ' Default'.pastel(:bright_white) puts ' gitaly/current' puts ' --raw gitlab-rails/production_json.log' puts ' gitlab-rails/api_json.log --sort=count' puts ' --search=pipeline sidekiq/current' puts puts ' Top'.pastel(:bright_white) puts ' top gitaly/current' puts ' top --limit=5 sidekiq/current' puts puts ' Errors'.pastel(:bright_white) puts ' errors gitaly/current' puts ' errors gitaly/current --no-border' end |
.list(args = []) ⇒ Object
List Files Helpers
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/greenhat/shell/faststats.rb', line 78 def self.list(args = []) unless TTY::Which.exist? 'fast-stats' faststats_installation return false end all = false all = true if args.include?('-a') || args.include?('--all') files = ShellHelper::Faststats.things # Sort files.sort_by!(&:name) # Short & Uniq files.uniq!(&:name) unless all # Print files.each do |log| if all puts "- #{log.friendly_name}" else puts "- #{log.name.pastel(:yellow)}" end end end |
.ls(args = []) ⇒ Object
105 106 107 |
# File 'lib/greenhat/shell/faststats.rb', line 105 def self.ls(args = []) list(args) end |
.top(raw) ⇒ Object
[ Fast Stats - Top ] ====================
Options: –display, value,perc,both
Show percentage of totals, actual durations, or both. Defaults to both.
–limit=X –sort=count,fail,max,median,min,p95,p99,rps,score
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/greenhat/shell/faststats.rb', line 140 def self.top(raw) unless TTY::Which.exist? 'fast-stats' faststats_installation return false end files, flags, cmd = ShellHelper::Faststats.parse(raw) LogBot.debug('FastStats CMD', cmd) if ENV['DEBUG'] results = ShellHelper.file_process(files) do |file| [ file.friendly_name, `fast-stats top #{cmd} #{file.file}`.split("\n"), "\n" ] end ShellHelper.show(results.flatten, flags) end |