Commit 096c200c authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Add worker label to prometheus metrics

As part of the work to reduce the amount of queues
Sidekiq has to listen to, here we introduce a worker
label that in the future will provide enough information
to query metrics per worker.

Today it's not strictly required given we
have an one-queue-per-worker approach (so we're
able to know which worker is causing issues through
its queue name).
parent 38b93f9f
...@@ -9,7 +9,13 @@ module Gitlab ...@@ -9,7 +9,13 @@ module Gitlab
private private
def create_labels(worker_class, queue) def create_labels(worker_class, queue)
labels = { queue: queue.to_s, urgency: "", external_dependencies: FALSE_LABEL, feature_category: "", boundary: "" } labels = { queue: queue.to_s,
worker: worker_class.to_s,
urgency: "",
external_dependencies: FALSE_LABEL,
feature_category: "",
boundary: "" }
return labels unless worker_class && worker_class.include?(WorkerAttributes) return labels unless worker_class && worker_class.include?(WorkerAttributes)
labels[:urgency] = worker_class.get_urgency.to_s labels[:urgency] = worker_class.get_urgency.to_s
......
...@@ -9,7 +9,14 @@ describe Gitlab::SidekiqMiddleware::ClientMetrics do ...@@ -9,7 +9,14 @@ describe Gitlab::SidekiqMiddleware::ClientMetrics do
let(:queue) { :test } let(:queue) { :test }
let(:worker_class) { worker.class } let(:worker_class) { worker.class }
let(:job) { {} } let(:job) { {} }
let(:default_labels) { { queue: queue.to_s, boundary: "", external_dependencies: "no", feature_category: "", urgency: "low" } } let(:default_labels) do
{ queue: queue.to_s,
worker: worker_class.to_s,
boundary: "",
external_dependencies: "no",
feature_category: "",
urgency: "low" }
end
shared_examples "a metrics client middleware" do shared_examples "a metrics client middleware" do
context "with mocked prometheus" do context "with mocked prometheus" do
......
...@@ -11,7 +11,14 @@ describe Gitlab::SidekiqMiddleware::ServerMetrics do ...@@ -11,7 +11,14 @@ describe Gitlab::SidekiqMiddleware::ServerMetrics do
let(:job) { {} } let(:job) { {} }
let(:job_status) { :done } let(:job_status) { :done }
let(:labels_with_job_status) { labels.merge(job_status: job_status.to_s) } let(:labels_with_job_status) { labels.merge(job_status: job_status.to_s) }
let(:default_labels) { { queue: queue.to_s, boundary: "", external_dependencies: "no", feature_category: "", urgency: "low" } } let(:default_labels) do
{ queue: queue.to_s,
worker: worker_class.to_s,
boundary: "",
external_dependencies: "no",
feature_category: "",
urgency: "low" }
end
shared_examples "a metrics middleware" do shared_examples "a metrics middleware" do
context "with mocked prometheus" do context "with mocked prometheus" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment