2019-07-29 07:53:12 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module SidekiqMiddleware
|
|
|
|
class Metrics
|
2019-11-22 13:06:00 -05:00
|
|
|
TRUE_LABEL = "yes"
|
|
|
|
FALSE_LABEL = "no"
|
|
|
|
|
2019-07-29 07:53:12 -04:00
|
|
|
private
|
|
|
|
|
2019-11-22 13:06:00 -05:00
|
|
|
def create_labels(worker_class, queue)
|
|
|
|
labels = { queue: queue.to_s, latency_sensitive: FALSE_LABEL, external_dependencies: FALSE_LABEL, feature_category: "", boundary: "" }
|
2020-01-23 10:08:46 -05:00
|
|
|
return labels unless worker_class && worker_class.include?(WorkerAttributes)
|
2019-11-22 13:06:00 -05:00
|
|
|
|
|
|
|
labels[:latency_sensitive] = bool_as_label(worker_class.latency_sensitive_worker?)
|
|
|
|
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-07-29 07:53:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|