module GreenHat::Shell::Faststats
Logs
Public Class Methods
default(raw, _other = nil)
click to toggle source
Vanilla Fast Stats
# File lib/greenhat/shell/faststats.rb, line 98 def self.default(raw, _other = nil) 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)
click to toggle source
¶ ↑
[ Fast Stats - Errors ] ====================¶ ↑
¶ ↑
# File lib/greenhat/shell/faststats.rb, line 143 def self.errors(raw) # 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
help()
click to toggle source
rubocop:disable Metrics/MethodLength)
# 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 = [])
click to toggle source
List Files Helpers
# File lib/greenhat/shell/faststats.rb, line 71 def self.list(args = []) 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 = [])
click to toggle source
# File lib/greenhat/shell/faststats.rb, line 93 def self.ls(args = []) list(args) end
top(raw)
click to toggle source
¶ ↑
[ 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
¶ ↑
# File lib/greenhat/shell/faststats.rb, line 123 def self.top(raw) 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