2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module SidekiqMiddleware
|
2021-02-22 17:27:13 +05:30
|
|
|
module MetricsHelper
|
2020-01-01 13:55:28 +05:30
|
|
|
TRUE_LABEL = "yes"
|
|
|
|
FALSE_LABEL = "no"
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
private
|
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
def create_labels(worker_class, queue)
|
2020-04-22 19:07:51 +05:30
|
|
|
labels = { queue: queue.to_s,
|
|
|
|
worker: worker_class.to_s,
|
|
|
|
urgency: "",
|
|
|
|
external_dependencies: FALSE_LABEL,
|
|
|
|
feature_category: "",
|
|
|
|
boundary: "" }
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
return labels unless worker_class && worker_class.include?(WorkerAttributes)
|
2020-01-01 13:55:28 +05:30
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
labels[:urgency] = worker_class.get_urgency.to_s
|
2020-01-01 13:55:28 +05:30
|
|
|
labels[:external_dependencies] = bool_as_label(worker_class.worker_has_external_dependencies?)
|
|
|
|
|
|
|
|
feature_category = worker_class.get_feature_category
|
|
|
|
labels[:feature_category] = feature_category.to_s
|
|
|
|
|
|
|
|
resource_boundary = worker_class.get_worker_resource_boundary
|
|
|
|
labels[:boundary] = resource_boundary == :unknown ? "" : resource_boundary.to_s
|
|
|
|
|
|
|
|
labels
|
|
|
|
end
|
|
|
|
|
|
|
|
def bool_as_label(value)
|
|
|
|
value ? TRUE_LABEL : FALSE_LABEL
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|