Class: GitLab::Monitor::CLI::GitProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_monitor/cli.rb

Overview

Process runner

Takes a pid and name for metrics

Constant Summary collapse

COMMAND_NAME =
"git-process".freeze

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ GitProcess

Returns a new instance of GitProcess.



297
298
299
300
301
302
303
# File 'lib/gitlab_monitor/cli.rb', line 297

def initialize(args)
  @options = options(args)
  @options.parse!

  @target = args.shift || STDOUT
  @target = File.open(@target, "a") if @target.is_a?(String)
end

Instance Method Details

#helpObject



314
315
316
# File 'lib/gitlab_monitor/cli.rb', line 314

def help
  @options.help
end

#options(args) ⇒ Object



305
306
307
308
309
310
311
312
# File 'lib/gitlab_monitor/cli.rb', line 305

def options(args)
  args.options do |opts|
    opts.banner = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]"
    opts.on("--quantiles", "Return quantiles instead of exact metrics") do
      @quantiles = true
    end
  end
end

#runObject



318
319
320
321
322
# File 'lib/gitlab_monitor/cli.rb', line 318

def run
  ::GitLab::Monitor::GitProcessProber.new(quantiles: @quantiles)
                                     .probe_git
                                     .write_to(@target)
end