Skip to content

Add gauge metric on ci queue size

Adrien Kohlbecker requested to merge ak/queue_metric into master

What does this MR do?

See #327594 (closed)

Adds additional metric gitlab_ci_current_queue_size similar to gitlab_ci_queue_size_total_bucket but exposed as a gauge rather than a histogram

Screenshots or Screencasts (strongly suggested)

How to setup and validate locally (strongly suggested)

pry(main)> @runner = Ci::Runner.last
  Ci::Runner Load (8.7ms)  SELECT "ci_runners".* FROM "ci_runners" ORDER BY "ci_runners"."id" DESC LIMIT 1 /*application:console,line:(pry):2:in `__pry__'*/
#<Ci::Runner:0x00007ffc9b0ee8c8> {
 ...
}

pry(main)> @metrics = ::Gitlab::Ci::Queue::Metrics.new(@runner)
#<Gitlab::Ci::Queue::Metrics:0x00007ffc9b1587f0  ...>

pry(main)> Feature.enable(:gitlab_ci_builds_queuing_metrics)
...
true

pry(main)> @metrics.observe_queue_size(->() { 5 }, @runner.runner_type)
5.0

pry(main)> ::Gitlab::Ci::Queue::Metrics.current_queue_size.values
{
    { :runner_type => "group_type" } => #<Prometheus::Client::MmapedValue:0x00007ffc9b438948 @file_prefix="gauge_all", @metric_name=:gitlab_ci_current_queue_size, @name=:gitlab_ci_current_queue_size, @labels={:runner_type=>"group_type"}, @pid=12088, @mutex=#<Thread::Mutex:0x00007ffc9b438858>, @file=#<Prometheus::Client::MmapedDict:0x442a0>, @key="[\"gitlab_ci_current_queue_size\",\"gitlab_ci_current_queue_size\",[\"runner_type\"],[\"group_type\"]]", @value=5.0>
}

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Mayra Cabrera

Merge request reports