Class: GitLab::Exporter::CLI::Process
- Inherits:
-
Object
- Object
- GitLab::Exporter::CLI::Process
- Defined in:
- lib/gitlab_exporter/cli.rb
Overview
Process runner
Takes a pid and name for metrics
Constant Summary collapse
- COMMAND_NAME =
"process".freeze
Instance Method Summary collapse
- #help ⇒ Object
-
#initialize(args) ⇒ Process
constructor
A new instance of Process.
- #options(args) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Process
Returns a new instance of Process.
233 234 235 236 237 238 239 |
# File 'lib/gitlab_exporter/cli.rb', line 233 def initialize(args) = (args) .parse! @target = args.shift || $stdout @target = File.open(@target, "a") if @target.is_a?(String) end |
Instance Method Details
#help ⇒ Object
259 260 261 |
# File 'lib/gitlab_exporter/cli.rb', line 259 def help .help end |
#options(args) ⇒ Object
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/gitlab_exporter/cli.rb', line 241 def (args) args. do |opts| opts. = "Usage: #{EXECUTABLE_NAME} #{COMMAND_NAME} [options]" opts.on("--pid=123", "Process ID") do |val| @pid = val end opts.on("--pattern=worker", "Process command pattern") do |val| @pattern = val end opts.on("--name=NAME", "Process name to be used in metrics") do |val| @name = val end opts.on("--quantiles", "Return quantiles instead of exact metrics") do @quantiles = true end end end |
#run ⇒ Object
263 264 265 266 267 268 269 |
# File 'lib/gitlab_exporter/cli.rb', line 263 def run ::GitLab::Exporter::ProcessProber.new(pid_or_pattern: @pid || @pattern, name: @name, quantiles: @quantiles) .probe_stat .probe_count .probe_smaps .write_to(@target) end |