Module: Metrician::Jobs

Defined in:
lib/metrician/jobs.rb,
lib/metrician/jobs/resque_plugin.rb,
lib/metrician/jobs/sidekiq_middleware.rb,
lib/metrician/jobs/delayed_job_callbacks.rb

Defined Under Namespace

Modules: ResquePlugin Classes: DelayedJobCallbacks, SidekiqMiddleware

Constant Summary collapse

RUN_METRIC =
"jobs.run".freeze
ERROR_METRIC =
"jobs.error".freeze

Class Method Summary collapse

Class Method Details

.configurationObject



7
8
9
# File 'lib/metrician/jobs.rb', line 7

def self.configuration
  @configuration ||= Metrician.configuration[:jobs]
end

.enabled?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/metrician/jobs.rb', line 11

def self.enabled?
  @enabled ||= configuration[:enabled]
end

.error?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/metrician/jobs.rb', line 19

def self.error?
  @error ||= configuration[:error][:enabled]
end

.instrumentation_name(job_name) ⇒ Object



27
28
29
# File 'lib/metrician/jobs.rb', line 27

def self.instrumentation_name(job_name)
  job_name.gsub(/[^\w]+/, ".").gsub(/\.+$/, "")
end

.job_specific?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/metrician/jobs.rb', line 23

def self.job_specific?
  @job_specific ||= configuration[:job_specific][:enabled]
end

.resetObject



31
32
33
34
35
36
37
# File 'lib/metrician/jobs.rb', line 31

def self.reset
  %i[@configuration @enabled @run @error @job_specific].each do |memo_ivar|
    if instance_variable_defined?(memo_ivar)
      remove_instance_variable(memo_ivar)
    end
  end
end

.run?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/metrician/jobs.rb', line 15

def self.run?
  @run ||= configuration[:run][:enabled]
end