Class: GitLab::Exporter::CLI::GitProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_exporter/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.



338
339
340
341
342
343
344
# File 'lib/gitlab_exporter/cli.rb', line 338

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



355
356
357
# File 'lib/gitlab_exporter/cli.rb', line 355

def help
  @options.help
end

#options(args) ⇒ Object



346
347
348
349
350
351
352
353
# File 'lib/gitlab_exporter/cli.rb', line 346

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



359
360
361
362
363
# File 'lib/gitlab_exporter/cli.rb', line 359

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