Class: Gitlab::SidekiqMiddleware::ClientMetrics

Inherits:
Metrics
  • Object
show all
Defined in:
lib/gitlab/sidekiq_middleware/client_metrics.rb

Constant Summary collapse

ENQUEUED =
:sidekiq_enqueued_jobs_total

Constants inherited from Metrics

Metrics::FALSE_LABEL, Metrics::TRUE_LABEL

Instance Method Summary collapse

Constructor Details

#initializeClientMetrics

Returns a new instance of ClientMetrics.


8
9
10
# File 'lib/gitlab/sidekiq_middleware/client_metrics.rb', line 8

def initialize
  @metrics = init_metrics
end

Instance Method Details

#call(worker_class, _job, queue, _redis_pool) ⇒ Object


12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/sidekiq_middleware/client_metrics.rb', line 12

def call(worker_class, _job, queue, _redis_pool)
  # worker_class can either be the string or class of the worker being enqueued.
  worker_class = worker_class.safe_constantize if worker_class.respond_to?(:safe_constantize)
  labels = create_labels(worker_class, queue)

  @metrics.fetch(ENQUEUED).increment(labels, 1)

  yield
end